Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/image/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在listview android中定义图像?_Android_Image_Listview - Fatal编程技术网

如何在listview android中定义图像?

如何在listview android中定义图像?,android,image,listview,Android,Image,Listview,我有一个包含以下代码的布局: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" style="@style/fundo" android:layout_width="fill_parent" android:layout_height="fill_parent" android:or

我有一个包含以下代码的布局:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
   style="@style/fundo"
   android:layout_width="fill_parent"
   android:layout_height="fill_parent"
   android:orientation="vertical" >

<TextView
    android:id="@+id/consoleListaSimples"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"/>

<ListView
    android:id="@+id/listaSimples"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content">
</ListView>

</LinearLayout>
设置文本效果很好,但对图像不起作用。
形象的价值何在?或者我应该改变什么才能工作?

我相信您必须创建扩展
BaseAdapter
的新适配器

以下是为您提供的一些教程:


如果仔细阅读这些教程,诀窍在于
getView()
的工作原理。

请参考以下包含示例代码片段的链接

每个列表项中都有一个文本视图和一个图像视图

每个列表项中有两个textview

每个列表项中有两个文本视图和一个图像视图

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" android:background="@drawable/bk_principal_small">

<LinearLayout
    android:id="@+id/linearLayout2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content">

    <LinearLayout
        android:id="@+id/linearLayout1"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" >

        <ImageView
            android:id="@+id/imagemStatus"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/green"/>

        <TextView
            android:id="@+id/texto1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/padrao" />
    </LinearLayout>

</LinearLayout>

</RelativeLayout>
this.adapter = new ListAdapterCreater(list.getContext(),itensList,
R.layout.list_simple_item,new String[] {"text","image"},
            new int[]{R.id.texto1,R.id.imagemStatus});