如何使用图片和摘要(项目列表文本下的文本)制作一个列表,对项目的描述很少。使用摘要制作ListActivity
我的代码与图片列表。我如何添加摘要?
<?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>
</LinearLayout>
活动类:
public class MyListActivity 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" };
// Use your own layout
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
R.layout.rowlayout, R.id.label, values);
setListAdapter(adapter);
}
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
String item = (String) getListAdapter().getItem(position);
Toast.makeText(this, item + " selected", Toast.LENGTH_LONG).show();
}
}
你能告诉我什么是摘要的方法,因为我更喜欢留在我的代码中。谢谢 – user1257040 2012-03-24 19:55:43
方法摘要?你是什么意思?如果你想适应你的问题,你可以在你的MyListActivity上使用你的xml和几乎相同的代码。你只需要创建一个适配器和getView(int position,View convertView,ViewGroup parent)。我会尽力完成我的答案。 – 2012-03-24 20:09:40
摘要=该项目下的小说明,它就像另一个文本视图。 – user1257040 2012-03-24 20:47:56