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

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -