How to solve "content must have a ListView whose id attribute is 'android.R.id.list' " Runtime error in Android? [closed]

StackOverflow https://stackoverflow.com/questions/23150587

Question

I know that this question may be marked as a duplicate but before any mod does that I'd wish to point out that I've tried those solutions and they didn't work out for me. My problem.(most likely) The fragment FirstPane fails to inflate. Here's the stacktrace.

BTW my code is open source. You can find it at https://github.com/Boggartfly/OpenAirplay

I hope you find my code reasonably good. I'm trying to stream content to my Apple TV so that why the apps named like that. Plus when this is done I'll post it on Google Play! Thanks a lot guys!

UPDATE: So here's what I actually know of this bug. Caused due to Android not finding the required ListView with id android.R.id.list

All known bug fixes do not work as of now. (Maybe I'm placing the bug fix in the wrong XML layout file) When fragment first pane is set as a ListFragment then compilation succeeds but a runtime exception is thrown and a Force Close Occurs.(Error inflating class Fragment Binary error in XML line 20). But when FirstPane extends a Fragment, setListAdapter(adapter); fails to compile.

Stack trace:-

    04-18 16:52:33.840: D/AndroidRuntime(11445): Shutting down VM
    04-18 16:52:33.850: E/AndroidRuntime(11445): FATAL EXCEPTION: main
    04-18 16:52:33.850: E/AndroidRuntime(11445): Process: code.laerstudios.openairplay,     PID: 11445
    04-18 16:52:33.850: E/AndroidRuntime(11445): java.lang.RuntimeException: Unable to start activity ComponentInfo{code.laerstudios.openairplay/code.laerstudios.openairplay.MainActivity}: android.view.InflateException: Binary XML file line #19: Error inflating class fragment
    04-18 16:52:33.850: E/AndroidRuntime(11445):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)
    04-18 16:52:33.850: E/AndroidRuntime(11445):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
    04-18 16:52:33.850: E/AndroidRuntime(11445):    at android.app.ActivityThread.access$800(ActivityThread.java:135)
    04-18 16:52:33.850: E/AndroidRuntime(11445):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
    04-18 16:52:33.850: E/AndroidRuntime(11445):    at android.os.Handler.dispatchMessage(Handler.java:102)
    04-18 16:52:33.850: E/AndroidRuntime(11445):    at android.os.Looper.loop(Looper.java:136)
    04-18 16:52:33.850: E/AndroidRuntime(11445):    at android.app.ActivityThread.main(ActivityThread.java:5017)
    04-18 16:52:33.850: E/AndroidRuntime(11445):    at java.lang.reflect.Method.invoke(Native Method)
    04-18 16:52:33.850: E/AndroidRuntime(11445):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
    04-18 16:52:33.850: E/AndroidRuntime(11445):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
    04-18 16:52:33.850: E/AndroidRuntime(11445): Caused by: android.view.InflateException: Binary XML file line #19: Error inflating class fragment
    04-18 16:52:33.850: E/AndroidRuntime(11445):    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:713)
    04-18 16:52:33.850: E/AndroidRuntime(11445):    at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
    04-18 16:52:33.850: E/AndroidRuntime(11445):    at android.view.LayoutInflater.rInflate(LayoutInflater.java:758)
    04-18 16:52:33.850: E/AndroidRuntime(11445):    at android.view.LayoutInflater.rInflate(LayoutInflater.java:758)
    04-18 16:52:33.850: E/AndroidRuntime(11445):    at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
    04-18 16:52:33.850: E/AndroidRuntime(11445):    at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
    04-18 16:52:33.850: E/AndroidRuntime(11445):    at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
    04-18 16:52:33.850: E/AndroidRuntime(11445):    at code.laerstudios.openairplay.MainActivity.onCreate(MainActivity.java:24)
    04-18 16:52:33.850: E/AndroidRuntime(11445):    at android.app.Activity.performCreate(Activity.java:5231)
    04-18 16:52:33.850: E/AndroidRuntime(11445):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
    04-18 16:52:33.850: E/AndroidRuntime(11445):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
    04-18 16:52:33.850: E/AndroidRuntime(11445):    ... 9 more
    04-18 16:52:33.850: E/AndroidRuntime(11445): Caused by: java.lang.RuntimeException: Your content must have a ListView whose id attribute is 'android.R.id.list'
    04-18 16:52:33.850: E/AndroidRuntime(11445):    at android.support.v4.app.ListFragment.ensureList(ListFragment.java:344)
    04-18 16:52:33.850: E/AndroidRuntime(11445):    at android.support.v4.app.ListFragment.onViewCreated(ListFragment.java:145)
    04-18 16:52:33.850: E/AndroidRuntime(11445):    at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:906)
    04-18 16:52:33.850: E/AndroidRuntime(11445):    at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1082)
    04-18 16:52:33.850: E/AndroidRuntime(11445):    at android.support.v4.app.FragmentManagerImpl.addFragment(FragmentManager.java:1184)
    04-18 16:52:33.850: E/AndroidRuntime(11445):    at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:291)
    04-18 16:52:33.850: E/AndroidRuntime(11445):    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685)
    04-18 16:52:33.850: E/AndroidRuntime(11445):    ... 19 more
Was it helpful?

Solution

Follow the stacktrace to the bottommost nested exception:

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

The layout you use with ListFragment (and ListActivity) must have a ListView with that id. You can set it in XML with

android:id="@android:id/list"
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top