I am nearly finished with my first Android App, but there is one thing that still bothers me: I have an activity with EditText fields and a "Start"-button that leads to a new Activity. When the user presses the back-button (the one thats on the phone), I get back to my first Activity. Can I change this and define a whole new Activity? A modified version of my first Activity?
Here is what I want to achieve:
First Activity - - > (start-button clicked) - - > Second Activity - - > (back-button clicked) - - > First Activity, modified.
Thanks for any help!
Use startActivityForResult
and onActivityResult
.
An example of this is here .
You will put your layout manipulation code as it were in the onActivityResult
method in your first activity, and start the second activity using startActivityForResult
.
override onBackPressed() in your second activity and start your modified activity from there. Something like:
@Override
public void onBackPressed()
{
//start your activity here
//make sure you remove the super call
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.