java.lang.RuntimeException: Your content must have a ListView whose id attribute is 'android.R.id.list'

后端 未结 4 1889
不思量自难忘°
不思量自难忘° 2020-12-10 15:31

I know that there has been simialr questions but I can\'t make it work even though I look at those. The error message is:

java.lang.RuntimeException:

4条回答
  •  执笔经年
    2020-12-10 15:55

    I decided to stop using actionbarsherlock and use the support libraries instead to get action bar in Android 2.1 and above. After doing this, i got the "java.lang.RuntimeException: Your content must have a ListView whose id attribute is 'android.R.id.list'". What i did to remedy this problem was

    to read this http://developer.android.com/reference/android/app/ListFragment.html#q=fragment

    then change my fragment layout file from

    
    

    to

    
    
     
    
     
    
     
    

    ... and voila, the RunTimeException with missing android.R.id.list was gone! Of course, i need to edit my new layout and fix it properly, but the key issue here was that i had overridden the fragment layout in its onCreateView method. ActionBarSherlock DID NOT have a problem with this, but with the Android support library, if u do this, you MUST have a ListView in your XML Layout, with the android:id="@id/android:list" as stated in the info linked to above.

    Hope this helps (coming from a total newb in Android app dev)!

提交回复
热议问题