Hy,
Я хочу добавить значок и 2 строки в один элемент ListView. Первым будут значения, а вторым будут значения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="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 для каждой строки:
<?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>
И мой код:
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);
Код не работает
Кто-нибудь может мне помочь?