이 블로그 검색

2011년 9월 9일 금요일

OnItemClick 에 체크 박스(CheckBox) 연동

우선 체크박스에, focusable, clickable을 모두 false 로 설정한다.
setXXX() 메서드를 사용해도 되고, 직접 xml에서 설정해도 된다.

예)
   vCheckBox.setFocusable(false);
   vCheckBox.setClickable(false);

그 후, 리스트 뷰의 onItemClick 메서드 안에

vCheckBox = (CheckBox)(this.getChildAt(position).findViewById(R.id.del_check));
넣는다. (현재의 리스트 뷰 위 이므로 this를 썼다. 만약 곳이라면 list.getChildAT ~~ 쓰면 된다.)

 
 public void onItemClick(AdapterView<?> adaptView, View view, int position,long id)
 {
  boolean checkTemp;
  WishListDBHelper helper = new WishListDBHelper(this.getContext(), "WishListDB" , 1);
  db = helper.getWritableDatabase();
  
  vCheckBox = (CheckBox)(this.getChildAt(position).findViewById(R.id.del_check));

  ................
  ...............
}

댓글 없음:

댓글 쓰기