I want to visible a edit button on my previous activity by going back using back button. But when I am using
@Override
public void onClick(View arg0) {
// finish the current activity
finish();
}
on my current activity, it is going back to previous activity, but edit button doesn’t become visible.
If I am using onResume on previous activity
@Override
protected void onResume() {
super.onResume();
btnEdit.setVisibility(View.VISIBLE);
}
then it’s always visible, no matter if the activity is resuming or created for the first time.
I am new in Android development, please help me to solve this problem.
Ok,
When you start the Activity, instead of
startActivity(intent)usestartActivityForResult(intent, 1989)(The 1989 can be whatever int you want).When you return from the new Activity, before calling
finish()do the following:Then in your first Activity override
onActivityResult()like so: