How To Implement A Drop Down Navigation Action Bar In Android After You've Added It?
By following this guide, http://wptrafficanalyzer.in/blog/adding-drop-down-navigation-to-action-bar-in-android/ I was able to add my drop down navigation bar. The click events and
Solution 1:
You need to maniputate your ArrayAdapter
if you want to change the elements, but I don't think you you can use the ArrayAdapter<String>
class for that porouse. You may need to use something else than string.
For handling clicks you need to change the onNavigationItemSelected
function:
@OverridepublicbooleanonNavigationItemSelected(int itemPosition, long itemId) {
switch(itemPosition) {
case0:
Intenti=newIntent(this, SecondActivity.class);
startActivity(i);
break;
case1:
// ...break;
}
returnfalse;
}
Solution 2:
You have to start a new Activity by calling startActivity(Intent)
in the onNavigationItemSelected
callback.
Solution 3:
Don't know if this is the exact problem you had (though it sounds like it!), but beware using startActivity from a spinner: it can be called during onCreate().
onNavigationItemSelected in ActionBar is being called at startup how can avoid it?
Post a Comment for "How To Implement A Drop Down Navigation Action Bar In Android After You've Added It?"