0
我想到了,我在創建時使用了相同的佈局,並顯示數據以便每次重複。Android ListView背景在每個條目後重復背景
我有一個數據列表顯示,由於某種原因,我設置的背景看起來不錯,但是在每兩個文本視圖之後,背景被擠壓成一個覆蓋原始背景的20px窗口。
我對我的看法XML看起來像這樣:
<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>
下面是放置到文本字段,並將其添加到屏幕上的Java:
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);
}
//
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);
它幾乎一樣,如果在每組文本字段之後還有另一個列表視圖,但我不知道如何擺脫它。請幫忙。