2017-08-08 39 views
0

當我試圖運行我的程序時,我有下一個錯誤。我看過其他類似的問題,這些人問他們是否在代碼中有列表視圖。問題是我的代碼中沒有List View或List Activities。你的內容必須有一個ListView的id屬性是'android.R.id.list'錯誤

這是我的項目GitHub

以下是錯誤日誌:

08-08 19:41:53.948 2473-2473/su.rck.networkcontrol E/AndroidRuntime: FATAL EXCEPTION: main 
Process: su.rck.networkcontrol, PID: 2473 
java.lang.RuntimeException: Unable to start activity ComponentInfo{su.rck.networkcontrol/su.rck.networkcontrol.BidListActivity}: java.lang.RuntimeException: Your content must have a ListView whose id attribute is 'android.R.id.list' 
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2193) 
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2243) 
at android.app.ActivityThread.access$800(ActivityThread.java:135) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:136) 
at android.app.ActivityThread.main(ActivityThread.java:5019) 
at java.lang.reflect.Method.invokeNative(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:515) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595) 
at dalvik.system.NativeStart.main(Native Method) 
Caused by: java.lang.RuntimeException: Your content must have a ListView whose id attribute is 'android.R.id.list' 
at android.support.v4.app.ListFragment.ensureList(ListFragment.java:346) 
at android.support.v4.app.ListFragment.onViewCreated(ListFragment.java:147) 
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1343) 
at android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1574) 
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1641) 
at android.support.v4.app.BackStackRecord.executeOps(BackStackRecord.java:794) 
at android.support.v4.app.FragmentManagerImpl.executeOps(FragmentManager.java:2415) 
at android.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2200) 
at android.support.v4.app.FragmentManagerImpl.optimizeAndExecuteOps(FragmentManager.java:2153) 
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2063) 
at android.support.v4.app.FragmentController.execPendingActions(FragmentController.java:388) 
at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:554) 
at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1188) 
at android.app.Activity.performStart(Activity.java:5241) 
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2166) 
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2243)  
at android.app.ActivityThread.access$800(ActivityThread.java:135)  
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)  
at android.os.Handler.dispatchMessage(Handler.java:102)  
at android.os.Looper.loop(Looper.java:136)  
at android.app.ActivityThread.main(ActivityThread.java:5019)  
at java.lang.reflect.Method.invokeNative(Native Method)  
at java.lang.reflect.Method.invoke(Method.java:515)  
+1

請不要只鏈接到您的項目以外。你需要在問題本身中包含[mcve]。 –

回答

1

您使用更改BidListFragment extends ListFragmentBidListFragment extends Fragment它將很好地工作。而你不使用ListFragment的任何財產,所以,你可以使用片段本身

檢查this

要做到這一點,您的視圖層次結構中必須包含一個ListView對象與 id爲「@android:ID /列表「(或列出它是否在代碼中)

相關問題