Reputation: 15492
I have 2 buttons
I want only one of them to be selected at most at a time.
how can i find a view's sibling while in onClick
?
I have tried:
siblingView = v.getParent().findViewById(R.id.rightBtn);
but parentView has no findViewById
method.
is it possible to get an ancestor view (even not direct) ? which is view for sure?
Upvotes: 0
Views: 77
Reputation: 3081
If I understand this correctly, you need some kind of tabs, not two buttons. Check this out for more details about how to implement that kind of behavior, using tabs not buttons.
Upvotes: 0
Reputation: 8128
getParentView
return type is an interface ViewParent
you can test if it is actually a View (or do not test, if you are sure), and downcast it to View.
Upvotes: 1