android - Why is my Navigation Drawer Fragment returning a Null Pointer Exception -


really need help. having trouble errors android studio generated navigation drawers. compiler gives 2 errors, starting setcontent line in main activity

protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.activity_main);  

this code xml file it's referencing:

<android.support.v4.widget.drawerlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/drawer_layout" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="com.example.app.mainactivity">  <!-- main content view, view below consumes entire      space available using match_parent in both dimensions. --> <framelayout     android:id="@+id/container"     android:layout_width="match_parent"     android:layout_height="match_parent" />  <!-- android:layout_gravity="start" tells drawerlayout treat      sliding drawer on left side left-to-right      languages , on right side right-to-left languages.      if you're not building against api 17 or higher, use      android:layout_gravity="left" instead. --> <!-- drawer given fixed width in dp , extends full height of      container. --> <fragment android:id="@+id/navigation_drawer"     android:layout_width="@dimen/navigation_drawer_width"     android:layout_height="match_parent"     android:layout_gravity="start"     android:name="com.example.app.navigationdrawerfragment" /> 

and main cause of problem (it seems me) code in navigationdrawerfragment class (the specific line .setadapter bit):

 @override public view oncreateview(layoutinflater inflater, viewgroup container,                          bundle savedinstancestate) {     mdrawerlistview = (listview) inflater.inflate(             r.layout.fragment_navigation_drawer, container, false);     mdrawerlistview.setonitemclicklistener(new adapterview.onitemclicklistener() {         @override         public void onitemclick(adapterview<?> parent, view view, int position, long id) {             selectitem(position);         }     });     mdrawerlistview.setadapter(new arrayadapter<string>(             getactionbar().getthemedcontext(),             android.r.layout.simple_list_item_activated_1,             android.r.id.text1,             new string[]{                     getstring(r.string.title_section1),                     getstring(r.string.title_section2),                     getstring(r.string.title_section3),             }));     mdrawerlistview.setitemchecked(mcurrentselectedposition, true);     return mdrawerlistview; } 

for once i'm absolutely clueless why null pointer exception being thrown, when it's automatically generated code. ideas?


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -