There is a Navigation Drawer in it a couple of fragments, and in one of them there is a button that should change the background in the Navigation Drawer menu. I can't even get the id layout to change its background. Here is the method code:

@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.menu_activity3, container, false); Button button1 = (Button) view.findViewById(R.id.button3); Layout asas = (Layout) getView().findViewById(R.layout.nav_header_navigation); button1.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { asas.setBackgroundResource(R.drawable.menu1); } }); return view; } 

this menu

  • Firstly, you will not succeed, because The left menu in the activation and you are looking for in the fragment layout. Secondly, you obviously have some kind of third-party lib zayuzana for the menu, but you did not even mention it. - Yuriy SPb
  • Yes, this is not my picture, and I could make a method in the Navigation Drawer class that changes the picture. But I don’t seem to be able to call it through the fragment, it says that I need a static method and when changing to a static method there is a markup declaration with a fragment, it says that findViewById does not work. - PaNDa11v48
  • You have not answered whether you use a third-party libu for a drover. Until you answer - you can not help. And I repeat - in the markup of the fragment there is no drover and there is no point in trying to look for him there - YuriySPb
  • Standard library - PaNDa11v48
  • 2
    Then you need something like this: View header = ((NavigationView)getActivity().findViewById(R.id.navigationDrawer)).getHeaderView(0); header.setBackgroundColor(Color.RED); View header = ((NavigationView)getActivity().findViewById(R.id.navigationDrawer)).getHeaderView(0); header.setBackgroundColor(Color.RED); - Yuriy SPb

0