0

カスタムビュー(画像+ frameLayout)を使用してリストビューを作成していますが、問題は、リストビューの任意のアイテムをクリックすると、getViewメソッドが最初のビューのアイテムの数と同じ数で呼び出されることです。

ここで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>

よろしくお願いします。

4

1 に答える 1

0

こんにちは、リストの 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/icon"
       />

   <LinearLayout 
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:background="#ffffff"
    android:orientation="vertical">

        <Button
            android:id="@+id/button1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Landed" 
            android:layout_gravity="center"
           />
            <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>

    </LinearLayout>

リスト項目については、ここをクリックしてください

すべてのリスト項目に対して同じクリックを行うことができ、異なるビュー(リスト項目を意味する)に対して異なるクリックを置くことができます。

クエリがある場合は非常に簡単で、以下にコメントしてください。

于 2012-10-31T06:58:28.183 に答える