그리드뷰에 아이템리스너를 줬는데, 그리드 뷰 안에 체크박스를 넣었는데 리스너가 먹히지 않습니다. ㅠ

 

다시 말씀 드리면 그리드뷰에 OnItemClickListener를 이용하여 해당하는 이벤트를 발생하는 것인데,

 

체크박스를 사용함으로써 갑자기 이벤트가 발생하지 않는 것입니다.

 

*.xml 부분입니다.

<?xml version="1.0" encoding="UTF-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center"
android:orientation="vertical" >

<RelativeLayout
android:id="@+id/rl_item"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerInParent="true" >

<ImageView
android:id="@+id/iv_FoodImage"
android:layout_width="100dp"
android:layout_height="100dp"
android:src="@drawable/icon" />

<CheckBox
android:id="@+id/checkBox1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="87dp" >
</CheckBox>
</RelativeLayout>

<TextView
android:id="@+id/tv_FoodName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/rl_item"
android:layout_centerInParent="true"
android:text="TextView"
android:textSize="18sp" >
</TextView>

<TextView
android:id="@+id/tv_FoodPrice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/tv_FoodName"
android:layout_centerInParent="true"
android:text="TextView"
android:textSize="18sp" >
</TextView>

</RelativeLayout>

 

 

*.java 파일 부분은

class FoodListAdapter extends BaseAdapter {

--------------------------------------------------------------------

  @Override
  public View getView(int position, View convertView,
    ViewGroup parent) {

   View v = getLayoutInflater().inflate(
     R.layout.item_general, null);

   // ImageView ivFoodImage = (ImageView) v
   // .findViewById(R.id.iv_FoodImage);


   TextView tvFoodName = (TextView) v
     .findViewById(R.id.tv_FoodName);   <--- 이 부분


   TextView tvFoodPrice = (TextView) v
     .findViewById(R.id.tv_FoodPrice);

   if (convertView != null) {
    /** 들어갈 음식의 이미지 삽입 */
    // ImageOperations IO = new ImageOperations(
    // arrCollections.get(position)
    // .getImgUrl());
    // iv.setImageBitmap(IO.bm);

    /** 들어갈 음식의 이름 삽입 */
    tvFoodName.setText(arrFoodList.get(position)
      .getFoodName() + " / " + position);

    /** 들어갈 음식의 가격 삽입 */
    tvFoodPrice.setText(arrFoodList.get(position)
      .getFoodPrice());
   } else {

   }
   return v;
  }
 }

 

 

 첨부파일로 첨부하였습니다. 전체적인 그리드뷰와 아이템별 표시

 

*.xml 소스를 보시면

 

RelativeLayout을 썼는데, 그 이후는 아시다시피

 

체크박스를 이미지 위에 씌우기 위해 하게 되었습니다.

 

답변 부탁드립니다.

 

--------------------------------------------------------< 추가 부분 >--------------------------------------------------------

 

제가 리스너 부분을 안넣었는데요. 리스너는 그리드 뷰에서 아이템을 이용해서 각 아이템별 이벤트를 하게 해놨었습니다.

 

아는 지인에게 물어보니 어댑터 클래스 내부적으로 리스너를 줘야 할 것 같다고 하더라고요.

 

그래서 지금 해보려고 시도중입니다.

 

  gvFoodList = (GridView) findViewById(R.id.gv_FoodList);           ← 그리드뷰 매핑시켜주고,

  gvFoodList.setAdapter(new FoodListAdapter());
  gvFoodList.setOnItemClickListener(new OnItemClickListener() {   ← 그리드뷰 아이템 별 이벤트

   @Override
   public void onItemClick(AdapterView<?> arg0, View arg1,
     int position, long arg3) {
     Intent intent = new Intent(
      OrderGeneralActivity.this,
      FoodsInfoDetailActivity.class);                                                       ← 액티비티 전환하는 부분입니다.

    // 어느 메뉴가 눌렸는지를 데이터를 보내는 부분이 필요하다.
    intent.putExtra("Menu", position);
    startActivity(intent);
   }
  });