Reputation: 127
I have a main activity that includes two buttons 'Submit' and 'Pick' and few images. Inside the activity i have two fragments named MyThings and MyPicks. I want to hide activity button 'Pick' in MyThings fragment but want to show in MyPicks fragment. How can i achieve this? Because i don't know how to initialize the button which is in main activity to that fragment so that i can hide and show button in fragments. Please Help
Upvotes: 1
Views: 1103
Reputation: 467
There are several ways to handle this situation.
Activity
named
showButton()
and hideButton()
and in that methods you hide and
show button. In your Fragment
s you can call these methods in
onCreateView()
Method since you can invoke Activity
methods from
Fragment
.Activity
when
creating and putting Fragment
in the container. I prefer the
second way.Upvotes: 3