2012-07-19 59 views
1

我正在通過數據庫和listview通過數據庫從我的dailogfragment中刪除項目。我能夠從列表視圖中刪除數據庫中的項目,並且能夠從列表視圖中刪除項目並刷新列表。正在刪除的listview項目後面的黑條 - android

但問題是,我得到某種類型的黑條(已刪除項目後面的背景)刪除項目後:圖像中http://i733.photobucket.com/albums/ww331/suntuu/Capture-1.png

你能看到我的默認背景是白色的(theme.holo。光),但在刪除這個黑色背景後彈出。

當我再次執行listview片段時,它消失了。

我現在已經很久沒有這個了。

這裏是我的XML佈局文件:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:cacheColorHint="#00000000" 
    android:orientation="vertical" > 

    <ListView 
     android:id="@+id/list1" 
     android:cacheColorHint="#00000000" 
     style="@style/AndroDev" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:dividerHeight="2dp" 
     android:paddingBottom="1dp" 
     android:paddingTop="1dp" /> 

</LinearLayout> 

,這裏是我的風格/ androdev:

<?xml version="1.0" encoding="utf-8"?> 
<resources xmlns:android="http://schemas.android.com/apk/res/android"> 

    <style name="AndroDev" parent="@android:style/Theme.Holo.Light"> 
     <item name="android:background">#F7F7F7</item> 

    </style> 

</resources> 

UPDATE:

從我listviee刪除樣式後,這個問題似乎不見了,但後來我堅持使用列表項背景的默認背景,我想要自定義。

那麼我怎麼能實現它。

+0

請發表你已經嘗試過 – sunil 2012-07-19 18:23:53

回答

0

試試這個:

在你的主XML其中包含的ListView,

只需添加以下屬性到你的ListView的XML: -

android:cacheColorHint="#00000000" 
+0

行的代碼,我這樣做,但它仍然是越來越黑,我已爲我的XML文件,並且我使用自定義樣式來設置每個listview項目的背景。這是這個問題的原因。 – user1304 2012-07-19 18:36:07

0

我也面臨着同樣的問題,添加以下行爲活動解決它的列表視圖實例

listView = (ListView)findViewById(R.id.listViewMain); 
     listView.setCacheColorHint(Color.TRANSPARENT); // add this line in your code 
+0

看到我的更新,你能幫上忙嗎? – user1304 2012-07-19 18:45:52