Android是有建立在ListView中包含的ImageView和TextView的

问题描述:

我使用的ListView simple_list_item_1这是建立在其代码是:Android是有建立在ListView中包含的ImageView和TextView的

<TextView xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@android:id/text1" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:textAppearance="?android:attr/textAppearanceLarge" 
    android:gravity="center_vertical" 
    android:paddingLeft="6dip" 
    android:minHeight="?android:attr/listPreferredItemHeight" 
/> 

我用这样的:

String functions[] = new String[] { "asdf", "asdfasdf", 
      "asdf", "asdfasdfasdf" }; 

    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     // TODO Auto-generated method stub 
     super.onCreate(savedInstanceState); 
     setListAdapter(new ArrayAdapter<String>(this, 
       android.R.layout.simple_list_item_1, functions)); 
    } 

它的工作好,但我问,如果android有一个内置的列表视图,它的每一行包含一个imageview和一个文本视图, 非常感谢你

不,没有布局与SDK中的ImageView和TextView。
但是,您可以轻松创建一个。您需要扩展ArrayAdapter并覆盖getView()。这里有一个基本的tutorial来帮助你。

您还可以使用结合了两个视图的android:drawable___属性之一。

+0

感谢您的回答,对您+1,我知道如何手动执行,但我只是问是否有构建它的事情,因为它是一个非常常见的列表视图,所以我认为谷歌应该建立这样一个列表,谢谢 – 2013-02-17 17:31:27

+0

不错的教程。谢谢。教程链接 – 2013-05-17 09:57:41

+0

重定向到404 – shivisuper 2016-10-18 07:03:43