java - getActionBar().setSelectedNavigationItem(position); -
i had nullpointerexception when used method above, instead of getsupportactionbar().setselectednavigationitem(position);
for future reference, how can android studio or intellijidea give me better tip on mistake. havent tried analyze -> inspect code
i received common mistake commonsguy sample demos.
it available in google's own effectivenavigation code sample as:
// set action bar. final actionbar actionbar = getactionbar(); here, actionbar stayed null , set
if(actionbar != null) statements , code managed run, until changed android support library method: getsupportactionbar()
this example google had managed run without showing me 3 "sections tabs"
your activity should extending appcompatactivity make possible use getsupportactionbar() method. please check if activity's theme not extending noactionbar.
Comments
Post a Comment