开发者

Android ListView Background repeats background after each entry

I figured it out I was using the same layout for my on create and to show the data so it was repeating everyting.

I have a list of data showing and for some reason the background I have set looks fine but after each two text views the background is squished into a 20px window overlaying the orginal background.

My xml for my view looks like so:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" > 

    <ListView
        android:background="@drawable/patriot_bg2"
        android:cacheColorHint="#00000000"
        android:id="@id/android:list"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_weight="1"
        android:drawSelectorOnTop="true"
         />

          <TextView  
    android:id="@+id/item_title"
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:textAppearance="?android:attr/textAppearanceMedium"
    android:background="#00000000"
    android:padding="2dp"
    android:textSize="20dp" />

    <TextView  
    android:id="@+id/item_subtitle"
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content"
    android:background="#00000000"
    android:cacheColorHint="#00000000" 
    android:padding="2dp"
    android:textSize="13dp" />

</LinearLayout>

Below is the Java that places the text into the text fields and adds it to the screen:

    for (int i = 0; i < nodes.getLength(); i++) {                           
            HashMap<String, String> map = new HashMap<String, String>();    

            Element e = (Element)nodes.item(i);
            map.put("main_content", XMLfunctions.getValue(e, "content"));
            map.put("name", XMLfunctions.getValue(e, "name"));
            mylist.add(map);            
       开发者_C百科 }       
//       
        ListAdapter adapter = new SimpleAdapter(ShowXMLPAR.this, mylist , R.layout.listplaceholder, 
                        new String[] {"main_content", "name" }, 
                        new int[] { R.id.item_title, R.id.item_subtitle });

       setListAdapter(adapter);

its almost as if there is another listview after each set of textfields but I am not sure how to get rid of it. Please help.


I had to use a seperate layout for the ListView items so only that would repeat and not the main layout.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜