Nav Header with login

Asked

Viewed 467 times

1

I have the Drawer navigation menu and in the header part I have only one image. I would like to put for the user to perform a login. As kids I would like to leave as in the image below:

inserir a descrição da imagem aqui

I would like to put the image the name and email of the user already logged in. Can someone help me, tell me if it’s too hard ? Thank you.

I have the code:

XML:

<?xml version="1.0" encoding="utf-8"?>

<TextView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:paddingTop="@dimen/nav_header_vertical_spacing"
    android:textSize="20dp"
    android:text="@string/label_header"
    android:textAppearance="@style/Base.TextAppearance.Widget.AppCompat.Toolbar.Subtitle"
    android:id="@+id/textView14"
    android:layout_centerVertical="true"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true" />

<TextView
    android:id="@+id/textViewLogo"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/label_headerSmall"
    android:layout_gravity="center_horizontal"
    android:layout_below="@+id/textView14"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true" />

  • How about you put in the codes you already have so we can start? Also, when using a screenshot to describe the problem, try writing an image description. Help can come from a(a) user(a) of screen readers. :)

  • @Pabloalmeida edited my question and put the xml I have.

2 answers

1

Fala Artur,

You’d better treat it directly in Java, when the user logs in, you save it to the local database, right?

Before setting this name and email values of the logged in user, you make an if, example:

if(logado){
    nome.setText(nome);
    email.setText(email);
}else{
    nome.setText("Você precisa se logar");
    email.setVisibility(View.GONE);
}

Hugs.

  • Leonardo, I understood what you meant. But my problem is that not even the login screen I have yet. =(

1


It’s Arthur, all right ?

Dude, there’s a really good book by Professor Nelson Glauber, the first Google Developer Expert in Latin America. And there is a chapter that he treats just what he needs, a Navigation Drawer with login, in the case with Google Plus and already pulls the photo of the user. Below is the link from the book, in case you want to take a look, and from Github with all the sources from this chapter of the book. I hope I helped. Hugs

Book

Github

  • Leonardo speaks. Blz yes guy. I will buy this book to give another studied on android. I also downloaded the project. Thanks for the expensive strength. Abs.

  • @Arturmafezzolijúnior Magina mano, we are together! If you need just talk, if you can solve your problem, mark as sulucionado there please =) And which one of the answers helped you solve.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.