I have a FragmentActivity
where I add a Fragment
.
Depending on some situation, I want to access Buttons
from that fragment's layout and change click listeners of them.
What I do is:
View view = myFragment.getView();
Button myButton = (Button) view.findViewById(R.id.my_button);
myButton.setOnClickListener(new MyClickListener());
But the view
variable is always null
.
How can I get the view of the activity?