まず、リスト エントリのカスタム レイアウトが必要です。ImageView 、 TextView 、および CheckBox を含む単純な RelativeLayout で十分です。
次に、BaseAdapter (または SimpleAdapter または CursorAdapter または ArrayAdapter など) を拡張できる独自のカスタム アダプターを作成することができます。アダプターは、リストのデータをカスタム レイアウトにバインドします。たとえば、データが Cursor に含まれている場合、次のようになります。
private class MyCustomAdapter extends CursorAdapter {
public MyCustomAdapter(Context context) {
super(context, null);
}
@Override
public View newView(Context context, Cursor cursor, ViewGroup parent) {
//Return a list item view
return getLayoutInflater().inflate(R.layout.my_custom_list_item_layout, parent, false);
}
@Override
public void bindView(View view, Context context, Cursor cursor) {
//Get views from layout
final ImageView imageView = (ImageView) view.findViewById(R.id.list_item_image);
final TextView textView = (TextView) view.findViewById(R.id.list_item_text);
final CheckBox checkBox = (CheckBox) view.findViewById(R.id.list_item_checkbox);
//Get data from cursor
final String text = cursor.getString(...);
//Add listener to the checkbox
checkBox.setOnClickListener(new OnClickListener() {...});
//Bind data
textView.setText(text);
}
}