I am following this link to implement actionbar.
i have modified this code like this
/** Defining Navigation listener */
ActionBar.OnNavigationListener navigationListener = new OnNavigationListener() {
@Override
public boolean onNavigationItemSelected(int itemPosition, long itemId) {
Toast.makeText(getBaseContext(), "You selected : " + actions[itemPosition] , Toast.LENGTH_SHORT).show();
if(actions[itemPosition] == "Bookmark")
startActivity(new Intent(this,Bookmark.class))
else if(actions[itemPosition] == "Subscribe")
startActivity(new Intent(this,Subscribe.class))
else
startActivity(new Intent(this,Share.class))
return false;
}
};
When i run this code it opens Bookmark activity . but it call over main layout like when it opens bookmark and i click back then it opens main activity. i want when i click on list for eg bookmark then only the activity should change not the title with list navigation. or is there any example that i should follow to call new activity when list navigation is called. i have also tried ActionBarSherlock it also change the textview on clicking list navigation not calling new activity
Try This instead of above
if(actions[itemPosition].compareTo("Bookmark")==0){
startActivity(new Intent(this,Bookmark.class));
}
else if(actions[itemPosition].compareTo("Subscribe")==0){
startActivity(new Intent(this,Subscribe.class));
}
else{
startActivity(new Intent(this,Share.class));
return false;
}
You cannot open new activity on current activity. That's not how it works. If you want to change the views within your activity when the item is clicked you can, and should look into fragments to do so.
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.