Call Another Layout

Asked

Viewed 1,205 times

1

When entering email and password the app should call another layout. I just can’t seem to do it...

Intent intent = new Intent(this, R.layout.activity_estado);
startActivity(intent);

Informs the following error: Cannot resolve constructor 'Intent' (model. Main, int);

I confess that I am beginner in Android.

Thanks in advance

2 answers

3

Instead of

Intent intent = new Intent(this, R.layout.activity_estado);
startActivity(intent);

Use

Intent intent = new Intent(this, ActivityEstado.class);
startActivity(intent);

The second parameter of Intent is the Class, not the layout.

  • Error: Unknown class: 'activity_status'.

  • Okay, that I understand. I want to know where the layout goes in this... :(

3


Are you putting the layout in place where it is necessary to insert a class. Basically in this your case, you will need to create another Activity, for example ActivityEstado, with his layout activity_estado.xml. Right after insert it into your manifest.xml. Once done, you can switch screens using the method startActivity(). Behold:

Main

Intent intent = new Intent(this, ActivityEstado.class);
startActivity(intent);

manifest.xml:

<activity android:name=".ActivityEstado"/>

See here in the Android documentation everything about Intent's and here in the article Android Intents - Tutorial

Browser other questions tagged

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