1

I am deleting an item through my dailogfragment from database and listview through database . I am able to delete the item from the database , from the listview , and able to refresh the list with the item deleted removed from the listview .

But the problem is i am getting some type of black bar ( background behind the deleted item ) immediately after deleting the item : http://i733.photobucket.com/albums/ww331/suntuu/Capture-1.png

in the image you could see my default background is white ( theme.holo.light) , but after deleting this black background pops out at the end .

When i am executing the listview fragment again , it goes away .

I am stuck with this for a very long time now .

Here's my xml layout file :

 <?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>

and here's my style/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:

After removing the style from my listviee this problem seems to be gone , but then i am stuck with using default background for list item background , which i want to be custom .

So how could i achieve it .

user1304
  • 225
  • 2
  • 4
  • 11

3 Answers3

0

Try this:

In your main XML which containing ListView,

just add following property to your ListView in XML:-

    android:cacheColorHint="#00000000"
Chintan Raghwani
  • 3,370
  • 4
  • 22
  • 33
  • ok , i did that , but still it's getting black , i've posted my xml file , and i am using a custom style to set the background of each listview item . Is that the reason of this problem . – user1304 Jul 19 '12 at 18:36
0

i too faced same issue, Added below line for listview instance in Activity solved it

    listView = (ListView)findViewById(R.id.listViewMain);
      listView.setCacheColorHint(Color.TRANSPARENT); // add this line in your code
AAnkit
  • 27,299
  • 12
  • 60
  • 71
0

SO I have solved it . The problem was with using my own style for getting the custom background for the listview item , which wasn't right .

So I implemented my custom background for listview rows using this : ListView item background via custom selector

Community
  • 1
  • 1
user1304
  • 225
  • 2
  • 4
  • 11