Hy、 ListViewの1つの項目にアイコンと2行を追加したいとします。最初の値になり、2番目はvalues2ListView Androidのアイテムごとの2行とアイコン
String[] values = new String[] { "Android", "iPhone", "WindowsMobile",
"Blackberry", "WebOS", "Ubuntu", "Windows7", "Max OS X",
"Linux", "OS/2" };
String[] values2 = new String[] `enter code here`{ "Android2", "iPhone2", "WindowsMobile2",
"Blackberry2", "WebOS2", "Ubuntu2", "Windows72", "Max OS X2",
"Linux2", "OS/22" };
リストのための私のxmlは次のようになります。
<?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" >
<ImageView
android:id="@+id/icon"
android:layout_width="22px"
android:layout_height="22px"
android:layout_marginLeft="4px"
android:layout_marginRight="10px"
android:layout_marginTop="4px"
android:src="@drawable/ic_launcher" >
</ImageView>
<TextView
android:id="@+id/label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@+id/label"
android:textSize="20px" />
<TextView
android:id="@+id/label2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@+id/label" />
</LinearLayout>
そして、私のコードは次のとおりです:各行について
<?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:orientation="vertical" >
<ListView
android:id="@+id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</ListView>
</LinearLayout>
私のXMLがある
public class listaNoua extends ListActivity {
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
String[] values = new String[] { "Android", "iPhone", "WindowsMobile",
"Blackberry", "WebOS", "Ubuntu", "Windows7", "Max OS X",
"Linux", "OS/2" };
String[] values2 = new String[] { "Android2", "iPhone2", "WindowsMobile2",
"Blackberry2", "WebOS2", "Ubuntu2", "Windows72", "Max OS X2",
"Linux2", "OS/22" };
ArrayAdapter<String> adapter = new ArrayAdapter<String> (this,R.layout.rowlayout, R.id.label2, values2);
setListAdapter(adapter);
}
私が追加した場合:
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,R.layout.rowlayout, R.id.label2, values2 , R.id.label, values);
コードが
誰が私を助けることができる動作しませんか?
はそれが唯一のカーソル上で動作しますが、より複雑な、どこかmatrixcursorの使用を暗示することになる、((基本的にIDのリストと項目のリストを結合するためのsimplelistadapterを参照) – njzk2