How to navigate from one screen to another screen
Solution 1:
The most trivial case (called from activity):
startActivity(new Intent(this, ActivityToLaunch.class));
More details here: http://developer.android.com/guide/topics/fundamentals.html
Solution 2:
OnClickListener onClickListener = new OnClickListener() {
@Override
public void onClick(View v) {
startActivity(new Intent(action));
}
};
Button button = (Button) findViewById(id);
button.setOnClickListener(onClickListener);
Solution 3:
Button x.setOnClickListener(new View.OnClickListener() {
public void onClick(View v)
{
Intent i = new Intent(y.this, Activity.class);
startActivity(i);
}
});
Here we've defined a listener for Button x. The OS will call this method and start the Activity referenced in Intent i.
Here's the official tutorial example: http://developer.android.com/guide/tutorials/notepad/notepad-ex2.html
Solution 4:
Button btn = (Button)findViewById(R.id.button1);
btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startActivity(new Intent(TestActivity.this,second.class));
}
});