मैं एक सूची दृश्य स्थापित करने की कोशिश कर रहा हूं और जब मैं एमुलेटर में चलाता हूं तो मुझे एक त्रुटि मिल रही है "आपकी सामग्री में एक आईडी विशेषता होना चाहिए android.R.id.list"।
फ़ाइल के लिए मेरा एक्सएमएल यहाँ है:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<!-- Main ListView
Always give id value as list(@android:id/list)
-->
<ListView
android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
जब मैं आरआईडी "सूची" के लिए जेनरेट की गई जावा फाइलों में जांच करता हूं तो वहां नहीं होता है। इसे ठीक करने का कोई तरीका?
Tnanks
उत्तर:
जवाब के लिए 0 № 1<ListView
android:id="@+id/mainListView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1" >
</ListView>
इसे आज़माएं
जवाब के लिए 0 № 2
<ListView
android:id="@id/android:list"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
उसकी कोशिश करो
जवाब के लिए 0 № 3
उपयोग करते समय android:id="@android:id/list"
आप एंड्रॉइड सिस्टम में पहले से परिभाषित आईडी का जिक्र कर रहे हैं। अपनी खुद की आईडी बनाने के लिए आपको निम्न का उपयोग करने की आवश्यकता है:
<listview id="@+id/insertListNameHere">
जवाब के लिए 0 № 4
जो कोड आपने लिखा है वह थोड़ा गलत है।
के बजाय,
<ListView
android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
उपयोग,
<ListView
android:id="@+id/list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>