This Code snippet tells how to navigate from one page to another page in android.
public class FirstScreen extends Activity {
Private Button button;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// get button from xml
setNavigation();
}
public void setNavigation() {
OnClickListener buttonListener = new OnClickListener() {
@Override
public void onClick(View v) {
String key1, key2;
String value1, value2;
// get the values
Intent i = new Intent(FirstScreen.this, SecondScreen.class);
i.putExtra(key1, value1);
i.putExtra(key2, value2);
startActivity(i);
}
};
button.setOnClickListener(buttonListener);
}
}
public void SecondScreen extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
String value1 = getIntent().getStringExtra(key1);
String value2 = getIntent().getStringExtra(key2);
}
}

