嘗試使用自定義遊標適配器將數據從數據庫顯示到列表視圖的問題。我想我已經追蹤到這個問題,無法從xml文件中'找到'我的listview元素。XML文件中的ListView未被拾取
在我的XML文件,我有這樣的:
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:orientation="horizontal"
android:layout_weight="7" >
<ListView
android:id="@+id/android:list"
android:background="?android:attr/activatedBackgroundIndicator"
android:choiceMode="singleChoice"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
</LinearLayout>
我有這個,我對我的活動主要的onCreate:
setContentView(R.layout.activity_trip_display);
.... // other code
tripList = (ListView) findViewById(R.id.list);
但最後一行產生名單不能在Eclipse中解決或不是字段'錯誤。
如果我在那裏添加「機器人」:
tripList = (ListView) findViewById(android.R.id.list);
它編譯OK,但然後我得到的變量「tripList」這會導致其他錯誤NPE空項。
任何想法?
編輯:好吧,我認爲我的問題是我的光標適配器 - 將發佈一個新的問題。謝謝大家的期待...
清理您的項目並重新運行。 – Piyush