0% found this document useful (0 votes)
6 views2 pages

Android Button Navigation Example

This Java code defines a Main2Activity class that extends the AppCompatActivity class. It initializes four button objects and sets onclick listeners for each button to launch a new activity when clicked, with each button starting a different activity - button1 starts MainActivity, button2 starts Main3Activity, and so on.

Uploaded by

Maria Abid
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views2 pages

Android Button Navigation Example

This Java code defines a Main2Activity class that extends the AppCompatActivity class. It initializes four button objects and sets onclick listeners for each button to launch a new activity when clicked, with each button starting a different activity - button1 starts MainActivity, button2 starts Main3Activity, and so on.

Uploaded by

Maria Abid
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

package [Link].

mainactivity;

import [Link];

import [Link];
import [Link];

import [Link];
import [Link];

public class Main2Activity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
setContentView([Link].activity_main2);
Button button1 = (Button) findViewById([Link].go_b1);
Button button2 = (Button) findViewById([Link].go_b2);
Button button3 = (Button) findViewById([Link].go_b3);
Button button4 = (Button) findViewById([Link].go_b4);

[Link](new [Link]()
{
@Override
public void onClick(View v) {
Intent i = new Intent([Link], [Link]);
[Link](i);
}
});

[Link](new [Link]()
{
@Override
public void onClick(View v) {
Intent i = new Intent([Link], [Link]);
[Link](i);
}
});

[Link](new [Link]()
{
@Override
public void onClick(View v) {
Intent i = new Intent([Link], [Link]);
[Link](i);
}
});

[Link](new [Link]()
{
@Override
public void onClick(View v) {
Intent i = new Intent([Link], [Link]);
[Link](i);

}
});

}
}

You might also like