안드로이드 공부하는 초보 학생입니다.
리스트에 멀티플 체크가 가능한 아이콘이 나오는 리스트를 만들고 싶은데요.
도저히 체크박스를 체크하는 로직을 못짜겠습니다.
뭐가 잘못되었는지 모르겟네요 ㅠㅠ


먼저 아답터에서 inflate 할 XML 입니다..

<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:stretchColumns="2">

<TableRow android:id="@+id/ListRow" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:gravity="center_vertical">

<ImageView android:layout_column="1" android:id="@+id/icon1"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:padding="2dip"
android:layout_marginLeft="5dip" />

<CheckedTextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/text1" android:layout_width="fill_parent"
android:layout_height="?android:attr/listPreferredItemHeight"
android:textAppearance="?android:attr/textAppearanceLarge"
android:gravity="center_vertical" android:checkMark="?android:attr/listChoiceIndicatorMultiple"
android:paddingLeft="6dip" android:paddingRight="6dip"
android:layout_column="2" />
</TableRow>
</TableLayout> 

이렇게 아이콘을 표시하는 ImageView 가 있고 체크가능한 텍스트 박스가 있습니다.
아래는 소스입니다.

public class CategoryListActivity extends Activity {
private ListView listView;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.category_list);

List<CategoryDTO> categoryList = new ArrayList();

for (int i = 0; i < 6; i++) {
CategoryDTO test = new CategoryDTO();
test.setCateSubject("test" + i);
test.setCateIcon("default.png");
categoryList.add(test);
test = null;
}

listView = (ListView) findViewById(R.id.categoryListView);
listView
.setAdapter(new CategoryAdapter(this, R.id.text1, categoryList));

listView.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView parent, View v, int position,
long id) {
CheckedTextView selectedText = (CheckedTextView) v
.findViewById(R.id.text1);

if (selectedText.isChecked()
&& (selectedText.getText()
.equals(((CategoryDTO) listView
.getItemAtPosition(position))
.getCateSubject()))) {
selectedText.setChecked(false);
} else {
selectedText.setChecked(true);
}

LOG.debug("tt.getText() = " + selectedText.getText());

LOG.debug("checked!! "
+ position
+ ": "
+ ((CategoryDTO) listView.getItemAtPosition(position))
.getCateSubject());
}
});

listView.setItemsCanFocus(false);
listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
}

/**
* 카테고리 아이콘을 보여주는 리스트 아답터
* @author Geunwon,Mo
*/
private static class CategoryAdapter extends ArrayAdapter<CategoryDTO> {

private Logger LOG = Logger.getLogger(CategoryAdapter.class);
private LayoutInflater mInflater;
private List<CategoryDTO> objects;
private Context context;

public CategoryAdapter(Context context, int textViewResourceId,
List<CategoryDTO> objects) {
super(context, textViewResourceId, objects);

mInflater = LayoutInflater.from(context);

this.objects = objects;
this.context = context;
}

/**
* Make a view to hold each row.
* @see android.widget.ListAdapter#getView(int, android.view.View,
*      android.view.ViewGroup)
*/
public View getView(int position, View convertView, ViewGroup parent) {
// A ViewHolder keeps references to children views to avoid
// unneccessary calls
// to findViewById() on each row.
ViewHolder holder;

// When convertView is not null, we can reuse it directly, there is
// no need
// to reinflate it. We only inflate a new View when the convertView
// supplied
// by ListView is null.
if (convertView == null) {
convertView = mInflater.inflate(R.layout.category_list_adapter,
null);

// Creates a ViewHolder and store references to the two children
// views
// we want to bind data to.
holder = new ViewHolder();
holder.text = (CheckedTextView) convertView
.findViewById(R.id.text1);
holder.icon = (ImageView) convertView.findViewById(R.id.icon1);

convertView.setTag(holder);
} else {
// Get the ViewHolder back to get fast access to the TextView
// and the ImageView.
holder = (ViewHolder) convertView.getTag();
}

// Bind the data efficiently with the holder.
holder.text.setText(objects.get(position).getCateSubject());

LOG.debug(context.getResources().toString());

// //get icon////
try {
InputStream is = null;
is = context.getAssets().open(
"icons/" + objects.get(position).getCateIcon());
Drawable dr = Drawable.createFromStream(is, objects.get(
position).getCateIcon());
holder.icon.setImageDrawable(dr);
} catch (Exception e) {

}
return convertView;
}

static class ViewHolder {
CheckedTextView text;
ImageView icon;
}

}

}

이렇게 구성하여 돌려보는데.
리스트를 표시하고 체크박스를 누르면 자기 멋대로 다른 아이템에 체크가 되네요 ㅠ
희안하게 위의 setOnItemClickListener 리스너에서  CheckedTextView selectedText = (CheckedTextView) v.findViewById(R.id.text1);으로 받아온 CheckedTextView 의 text는 제대로 받아옵니다 ㅠ

전제조건은 ListActivity 를 상속받지 않고 Activity 만을 상속하여 구현하고 있습니다.
어떤 이유로 이런현상이 발생하는지.. 하루종일 이것만 붙잡고 있네요 ㅠ

도움부탁드립니다 ㅠㅠㅠ