views:

31

answers:

1

Hi,

I have created four tabs using tabhost, and placed four listviews in each like below:

public class prem extends ListActivity {

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);

    String[] names = new String[] { "Pr"};


    this.setListAdapter(new ArrayAdapter<String>(this,
            R.layout.simple_list_item_checked, names));
}

Problem is I have created background images for each listview but when I scroll the listview goes black, I know that I should add android:cacheColorHint="#00000000" to the xml file to make the listview transparent, so I have created a new xml and id and tried to add android:cacheColorHint="#00000000" in the xml to make transparent, but it just force closes;

this.setListAdapter(new ArrayAdapter(this, R.layout.list_item, R.id.listb, names));

?xml version="1.0" encoding="utf-8"?>

LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

android:layout_width="wrap_content" 
android:layout_height="wrap_content">
<TextView android:text="@+id/TextView01" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:textSize="30px"></TextView>
 <ListView android:id="@+id/listb" 
 android:layout_height="wrap_content"
 android:layout_width="fill_parent">
 </ListView>

+1  A: 

Have you tried to add setCacheColorHint(00000000) in the prem java file?

ListView lv = getListView();    
lv.setCacheColorHint(00000000);    
lv.setAdapter(new ArrayAdapter<String>(this,
        R.layout.simple_list_item_checked, names));
HappyGeisha
how would i do this with the code I have
JonniBravo
I edited my comment to match the code from your post. Try replacing this.setListAdapter(...) with what I wrote.
HappyGeisha
Thank you that worked perfectly, I now need to figure out how to add different backgrounds to each of the four listviews. Thanks your a star
JonniBravo