0
down vote
favorite
share [fb]
share [tw]
i am writing a simple application which can press a previous/next
button to switch from one page to another.
I have a main activity and listen to a button. if it is press, then
trigger activity 2 to show page 2. when page 2 finish, it return to
main activity again, which will trigger activity 3 to show page 3.
when page 3 finish, it return to main activity again.
however, i found that it always show page 3 first and then page 2.
why? any hints are highly appreciated. Please also suggest if you have
other ways to do it. Thanks a lot.
======= simplified version ===============
main.java
public class main extends Activity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.mainscr);
Button submitButton = (Button) findViewById(R.id.submit);
submitButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
start_act2();
start_act3();
}
});
}
private void start_act2() {
Intent i = new Intent(this, act2.class);
startActivity(i);
}
private void start_act3() {
Intent i = new Intent(this, act3.class);
startActivity(i);
}
}
act2.java (page 2)
=======================================
public class act2 extends Activity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.act2scr);
previousButton_act2.setOnClickListener(new View.OnClickListener()
{
public void onClick(View view) {
setResult(RESULT_OK);
finish();
}
});
nextButton_act2.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
setResult(RESULT_OK);
finish();
}
});
}
}
act3.java (page3)
=======================================
public class act3 extends Activity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.act3scr);
previousButton_act3.setOnClickListener(new View.OnClickListener()
{
public void onClick(View view) {
setResult(RESULT_OK);
finish();
}
});
nextButton_act3.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
setResult(RESULT_OK);
finish();
}
});
}
}
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en