I'm new to Stack, my question is this: I want to change the user and mail text of a nav header from a fragment. I have an application that when logging passes some parameters to the menuActivity and from there I update the data of the nav header, all right there. But my menu has a fragment where I can also update the data but I can not get it updated in the navheader. Is there any way to achieve it? From the activity I updated the navheader in the following way:
MenuActivity.java
NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
navigationView.setNavigationItemSelectedListener(this);
View header = navigationView.getHeaderView(0);
txtUser = (TextView) header.findViewById(R.id.txtUser);
txtEmail = (TextView) header.findViewById(R.id.textViewPass);
txtUser.setText(variables.vUsuario);
txtEmail.setText(variables.vCorreo);
How can I apply that method in a fragment? since I can not use (this) in a fragment and the navigationView.getHeaderView (0) marks me with some type of null error.
Thanks in advance. I'm new to this part of Android.