1
我試着做一個列表框,每個列出的項目有不同的圖像和文本。我試圖創建兩個setListAdapter,一個用於顯示文本字符串,另一個用於圖像名稱。它沒有工作,我假設有另一種方法來做到這一點。Android的listview,想在我的列表視圖的每一行有不同的圖片
我CTICTY類的名單
public class cFashions extends ListActivity {
TextView selection;
// list to fill list box wi*/
/*
String[] items={"CASUAL","DR ESSES","CAREER","OUTWEAR","FOOTWEAR",
"JEWELRY","ACCESSORIES"};
*/
String[] items={"CASUAL"};
String[] icons={"icon"};
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.fashions);
setListAdapter(new ArrayAdapter<String>(this,
R.layout.row, R.id.label,
items));
setListAdapter(new ArrayAdapter<String>(this,
R.layout.row, R.id.icon,
icons));
selection=(TextView)findViewById(R.id.selection);
}
}
爲每個單元的佈局XML文件中的列表
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<ImageView
android:id="@+id/icon"
android:layout_width="22px"
android:paddingLeft="2px"
android:paddingRight="2px"
android:paddingTop="2px"
android:layout_height="wrap_content"
/>
<TextView
android:id="@+id/label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="12sp"
/>
</LinearLayout>
特德
不錯的作品CommonsWare – BonanzaDriver 2011-03-07 04:54:22
它非常有用的CommonsWare – 2012-07-05 09:51:03