显示在一个列表行项目的两种观点中的Android [英] Displaying Two Views in a single List Row Item in Android
本文介绍了显示在一个列表行项目的两种观点中的Android的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有必要在一个单一的ListView行显示的两个视图。它是如何可能的机器人。请帮我。
There is a need to displaying two views in a single ListView Row . How it is possible in android. Please help me.
推荐答案
您可以使用自定义布局的名单,我这里是这是在单行使用的ImageView和TextView中。 Row.xml
You can use custom layout for your lists , here is example which is using imageview and textview in a single row. Row.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:padding="2dip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ok"
/>
<TextView
android:id="@+id/label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="40sp"
/>
</LinearLayout>
下面是用java code,这是一个活动的onCreate扩展ListActivity。
Here is java code ,this is an activity's onCreate extending ListActivity.
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.main);
setListAdapter(new ArrayAdapter<String>(this,R.layout.row, R.id.label,items));
selection=(TextView)findViewById(R.id.selection);
}
这篇关于显示在一个列表行项目的两种观点中的Android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文