我使用自定义视图(image + frameLayout)创建列表视图,但问题是当我点击列表视图上的任何项目时,getView方法被称为等于ilst视图中的项目数,ListView中的CustomView
我在这里给我的xmi文件。
custon_layout.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"
android:padding="5dp">
<ImageView
android:id="@+id/imageView1"
android:layout_width="70dp"
android:layout_height="70dp"
android:src="@drawable/ic_launcher"
/>
<FrameLayout
android:id="@+id/frame"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Landed"
android:layout_gravity="center"
/>
<LinearLayout
android:id="@+id/ll1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#ffffff"
android:orientation="vertical" >
<TextView
android:id="@+id/from_user"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="hi"
android:textColor="#000000" />
<TextView
android:id="@+id/from_user_id"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="hi"
android:textColor="#000000" />
</LinearLayout>
</FrameLayout>
</LinearLayout>
请帮助我,提前感谢。
我想你想如果你的视图有2个文本和一个图像,那么只有文本有不同的点击事件和图像有不同的点击事件。是吗 ? –
不要使用框架布局,只能使用线性布局来处理此问题。代码检查此:http://stackoverflow.com/a/12813906/1168654 –
您的问题是为什么getView方法被重复调用。我对吗? –