I have a main Activity: MainMenu

And Fragment: Settings

How can I change the color of something in MainMenu from Settings

PS color is XML that is bound to MainMenu

1 answer 1

From the fragment you can contact the activity through the following structure:

((MainMenu)getActivity()) 

To change an item, refer to it like this.

 ((MainMenu)getActivity()).someElement.setColor(red); 
  • And if not from a fragment? - Justit
  • What should I insert into "someElement" if my object has id "main_nav" - Justit 5:34 pm
  • findViewById (R.id.main_nav) - Vladimir Yarovoy pm