1
I have a Navigationdrawer with two Edittext and I would like these two fields to demonstrate the user data the name and email, but in my Telaprincipal class when I try to play the information for one of the two fields is demonstrated twice the Navigationdrawer.
XML
<?xml version="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);
}
Have you looked at this code snippet?
tvNome.setText("Denis");
 tvNome.setText("[email protected]");
– Luídne
Hello Luídne, as I said this duplicating the Navigation Drawer the information of the name and email is demonstrating, but the duplicity is wrong, I will try to put the image of the app to facilitate understanding.
– dnsfirmino