NullPointerException when using CustomListAdapter

后端 未结 3 1738
野性不改
野性不改 2020-12-18 12:03

I create CustomListAdapter in Android Appiclation. But i get this error NullPointerException when implement it.

Here is my CustomListAdapter.java code :

相关标签:
3条回答
  • 2020-12-18 12:09

    add AppController(Activity request) to your manifest:

     <application
        android:name=".AppController" //this one
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme">
    
    0 讨论(0)
  • 2020-12-18 12:27

    I noticed that you use private List<com.fanjavaid.searchhttprequest.model.Menu> menuList = new ArrayList<com.fanjavaid.searchhttprequest.model.Menu>();, but you never actually add anything to that list before you call:

    listView = (ListView) findViewById(R.id.list);
    adapter = new CustomListAdapter(this, menuList);
    listView.setAdapter(adapter);
    

    You probably want to put something in that menuList

    0 讨论(0)
  • 2020-12-18 12:31

    I think you didn't add AppController to your manifest:

     <application
            android:name=".AppController" //this one
            android:allowBackup="true"
            android:icon="@drawable/ic_launcher"
            android:label="@string/app_name"
            android:theme="@style/AppTheme">
    

    That's why onCreate never called and mInstance is null.

    0 讨论(0)
提交回复
热议问题