I am developing a navigation box application. Although I have no previous experience with fragments, I could successfully implement the navigation box. Now my problem is that I have a return button to the action bar. I tried this before for classes. But now the problem is that I have a fragment in which there is a click event inside it. When the user clicks the button, he goes to an activity in which there is a list view. Now I want to go back to the previous snippet using the action bar button. How can I do it? It works correctly when I press a button on my phone.
I have included onOptionsItemSelected as shown below in my list view activity. When I press the up button, it goes to the login window. Not where I wanted him to go.
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
Intent upIntent = NavUtils.getParentActivityIntent(this);
if (NavUtils.shouldUpRecreateTask(this, upIntent)) {
TaskStackBuilder.create(this)
.addNextIntentWithParentStack(upIntent)
.startActivities();
} else {
NavUtils.navigateUpTo(this, upIntent);
}
return true;
}
return super.onOptionsItemSelected(item);
}
Can someone help in solving the problem?
source
share