2013-10-01 48 views
0

我有一個空的ListView問題,我只想顯示消息,當數據庫中存在一些數據....但我得到這條線上的錯誤與空`ListView`問題

android:id="@*android:id/list"android:id="@*android:id/empty"

錯誤是:

Illegal resource reference: @*android resources are private and not always present 

我的代碼是這樣.....

<ListView 
     android:id="@*android:id/list" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:listSelector="@*android:color/transparent" 
     android:drawSelectorOnTop="false" 
     android:cacheColorHint="#00000000" 
     android:divider="@drawable/line" 
     android:dividerHeight="3.0dip" /> 

    <TextView 
     android:id="@*android:id/empty" 
     android:textColor="#ff777777" 
     android:gravity="center" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:text="No data" /> 
</LinearLayout> 

請幫我在這...

+0

刪除* s來解決您的問題。 –

回答

0

刪除asterik(*)之前的ID,

這裏是你更新的佈局

<ListView 
     android:id="@android:id/list" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:listSelector="@android:color/transparent" 
     android:drawSelectorOnTop="false" 
     android:cacheColorHint="#00000000" 
     android:divider="@drawable/line" 
     android:dividerHeight="3.0dip" /> 

    <TextView 
     android:id="@android:id/empty" 
     android:textColor="#ff777777" 
     android:gravity="center" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:text="No data" /> 
</LinearLayout> 
+0

亞它刪除*代碼後工作....謝謝很多#Brontok – user2833582

+0

請接受此答案。 –

0

無處不在,你有

@*android 

更改爲

@android 
0

使用下面的代碼。

<LinearLayout> 
     <ListView 
      android:id="@+id/list" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:listSelector="@*android:color/transparent" 
      android:drawSelectorOnTop="false" 
      android:cacheColorHint="#00000000" 
      android:divider="@drawable/line" 
      android:dividerHeight="3.0dip" /> 

     <TextView 
      android:id="@+id/empty" 
      android:textColor="#ff777777" 
      android:gravity="center" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:text="No data" /> 
    </LinearLayout> 
1

更改此

<ListView 
    android:id="@android:id/list" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:listSelector="@*android:color/transparent" 
    android:drawSelectorOnTop="false" 
    android:cacheColorHint="#00000000" 
    android:divider="@drawable/line" 
    android:dividerHeight="3.0dip" /> 

<TextView 
    android:id="@android:id/empty" 
    android:textColor="#ff777777" 
    android:gravity="center" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:text="No data" /> 

代碼也可以使用下面的代碼爲您的數組列表的消息空數組列表

if(arrayList.isEmpty()) 
    { 
     // do your message code here 
    } 
+0

它的工作#Ameer ...現在我沒有geting任何錯誤...感謝您的回覆 – user2833582

0

刪除 「*」從您的佈局代碼並嘗試以下代碼:

<ListView 
     android:id="@android:id/list" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:listSelector="@*android:color/transparent" 
     android:drawSelectorOnTop="false" 
     android:cacheColorHint="#00000000" 
     android:divider="@drawable/line" 
     android:dividerHeight="3.0dip" /> 

    <TextView 
     android:id="@android:id/empty" 
     android:textColor="#ff777777" 
     android:gravity="center" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:text="No data" /> 
</LinearLayout>