I have a NavigationDrawer with two EditText and I would like these two fields to show up the user's name and email data, however in my TelaPrincipal class when I try to throw the information to one of the two fields it is demonstrated twice in the NavigationDrawer.
XML
<?xmlversion="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="@dimen/nav_header_height"
android:background="@drawable/side_nav_bar"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:theme="@style/ThemeOverlay.AppCompat.Dark"
android:orientation="vertical"
android:gravity="bottom">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/telaprincipal_nav_header_et_meuperfil"
android:layout_marginBottom="2dp"
android:layout_marginTop="60dp"
style="@style/TextoMenuDrawerTituloPerfil"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="@+id/nav_header_telaprincipal_tv_nome"
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="@style/TextoMenuDrawerTitulo"
android:text=""
android:textAppearance="@style/TextAppearance.AppCompat.Body1" />
<TextView
android:id="@+id/nav_header_telaprincipal_tv_email"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="2dp"
style="@style/TextoMenuDrawerNormal"
android:text="" />
</LinearLayout>
</LinearLayout>
Java class
public class TelaPrincipal extends BaseActivity
implements NavigationView.OnNavigationItemSelectedListener {
//Componentes da Activity
private Context mContext;
private DrawerLayout mDrawerLayout;
private NavigationView navigationView;
private View mView;
private TextView tvNome;
private TextView tvEmail;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.telaprincipal);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
//Titulo da Activity
setTitle(getString(R.string.telaprincipal_titulo_activity));
//inicializando as variaveis
inicializaVariavel();
inicializaAcao();
//Método do Navegation Drawer
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar, R.string.telaprincipal_drawer_aberto, R.string.telaprincipal_drawer_fechado);
drawer.setDrawerListener(toggle);
toggle.syncState();
navigationView = (NavigationView) findViewById(R.id.nav_view);
navigationView.setNavigationItemSelectedListener(this);
LayoutInflater layoutInflater = getLayoutInflater();
mView = layoutInflater.inflate(R.layout.nav_header_tela_principal, navigationView, false);
tvNome = (TextView) mView.findViewById(R.id.nav_header_telaprincipal_tv_nome);
tvEmail = (TextView) mView.findViewById(R.id.nav_header_telaprincipal_tv_email);
tvNome.setText("Denis");
tvNome.setText("[email protected]");
navigationView.addHeaderView(mView);
}