0

リストビューのフッターにボタンを追加したい、水平リストビューを使用している、アダプタークラス

public ItemAdapter(Context context, int layout, Cursor c,String[] from, int[] to) {
        super(context, layout, c, from, to,0);
        this.layout = layout;
        inflator= LayoutInflater.from(context);

    }

newView と bindView を返します。

    public View newView(Context context, Cursor cursor, ViewGroup parent) {     
        View v = inflator.inflate(layout, parent, false);
        TextView footer = (TextView)v.findViewById(R.id.bAdd);
        return v;

    }

    @Override
    public void bindView(View v, final Context context, Cursor c) {
        final int id = c.getInt(c.getColumnIndex(ItemDb.ID));
        final String name = c.getString(c.getColumnIndex(ItemDb.NAME));
        }

そして活動クラス:

public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);     
        String[] from = new String[] { ItemDb.NAME, ItemDb.CONDITION, ItemDb.EMAIL};
        int[] to = new int[] { R.id.etItemName, R.id.etItemCondition, R.id.etEmail };
        itemAdapter = new ItemAdapter(this,R.layout.list_item, null, from, to);
        this.setListAdapter(itemAdapter);
    }

リストビューのフッターにボタンを追加するにはどうすればよいですか? ここに私のxmlがあります

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <ImageView
        android:id="@+id/photo"
        android:layout_width="85dp"
        android:layout_height="85dp"
        android:background="@drawable/photo_frame"
        android:contentDescription="@string/imagedescription"
        android:src="@drawable/ic_launcher" >
    </ImageView>


    <RelativeLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" >

        <TextView
            android:id="@+id/condition"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@id/name"
            android:layout_marginLeft="10dp"
            android:text="@string/condition"
            android:textColor="#000"
            android:textSize="14sp" />

        <TextView
            android:id="@+id/email"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@id/condition"
            android:layout_marginLeft="10dp"
            android:text="@string/email"
            android:textColor="#000"
            android:textSize="14sp" />

    </RelativeLayout>

</LinearLayout>
4

1 に答える 1