안드로이드 개발 질문/답변
(글 수 45,052)
public class If_AllDelete extends Activity {
list.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> view, View parent,
int position, long id) {
delete_Checkbox.setChecked(true);
Log.i("TEST", "position : " + position + " / id :" + id
+ " / num :" + num + " / " + view.getId());
int count = list.getChildCount();
for (int i = 0; i < count; i++) {
delete_Checkbox = (CheckBox) list.getChildAt(i)
.findViewById(R.id.FirstCheckBox);
System.out.println("postion : " + position + " / "
+ "checkTest : " + delete_Checkbox.isChecked()); }
delete_Checkbox.setChecked(!delete_Checkbox.isChecked());
cAdapter.notifyDataSetChanged(); }
});
private class CheckBoxAdapter extends SimpleCursorAdapter implements
OnCheckedChangeListener {
Cursor c;
public CheckBoxAdapter(Context context, int layout, Cursor c,
String[] from, int[] to) {
super(context, layout, c, from, to);
this.c = c;
}
@Override
public View getView(final int position, View view, ViewGroup parent) {
// TODO Auto-generated method stub
if (view == null) {
LayoutInflater inflater = getLayoutInflater();
view = inflater
.inflate(R.layout.address_checkboxlistview, null);
}
nameTv = (TextView) view.findViewById(R.id.Name_Text);
phoneTv = (TextView) view.findViewById(R.id.Phone_Text);
imgUri = (ImageView) view.findViewById(R.id.photo_img);
c.moveToPosition(position);
nameTv.setText(c.getString(c
.getColumnIndexOrThrow(DB_Provider.KEY_NAME)));
phoneTv.setText(c.getString(c
.getColumnIndexOrThrow(DB_Provider.KEY_PHONE)));
imgUri.setImageURI(Uri.parse(c.getString(c
.getColumnIndexOrThrow(DB_Provider.KEY_IMG))));
CheckBox delete_Checkbox = (CheckBox) view
.findViewById(R.id.FirstCheckBox);
delete_Checkbox.setOnCheckedChangeListener(this);
delete_Checkbox.setTag(c.getInt(c
.getColumnIndexOrThrow(DB_Provider.KEY_ID)));
return view;
}
public void onCheckedChanged(CompoundButton view, boolean isChecked) {
if (isChecked) {
@Override
cv.put("" + view.getTag(), true);
Log.i("cv put : ", cv.toString());
} else {
cv.remove("" + view.getTag());
Log.i("cv remove : ", cv.toString());
}
}
@Override
public void bindView(View view, Context context, Cursor cursor) {
// TODO Auto-generated method stub
}
@Override
public View newView(Context context, Cursor cursor, ViewGroup parent) {
// TODO Auto-generated method stub
return null;
}
안녕하세요 소스짜다가 안되는게 잇어서 고민하다가 이렇게 글을 올립니다
체크박스 [ ] 리스트 내용 출력후
위와 같이 소스를 일단 짯습니다.
저는 리스트뷰 클릭시 체크박스를 대개 할려고 합니다 근데 이상하게
어떤리스트를 클릭하든 처음 체크박스만 체크표시만 됩니다 로그창보시면 아시겟지만 ;;
처음꺼 다 false엿다가 리스트 클릭하면 처음꺼만 true 다시 다른거 클릭하면
마지막꺼와 처음께 true
읔 이런데서 막히니 ㅠ
좀 도와주세여 ㅠ_ㅠ 힌트라도




관련 이슈가 간간히 질문 게시판에 올라왔구요. 답변 또한 달려 있는 것으로 알고 있습니다.
조금만더 검색해보시면 좋은 정보 얻으실 수 있을꺼에요