[안드로이드]버튼을 가지고있는 리스트뷰 아이템 클릭리스너가 안먹혀요..

조회수 2286회

리스트뷰 아이템에 버튼을 가지고 있으면 focusable:"false"이걸주라길래 2개의 버튼에 다 그렇게 줬는데!

리스트뷰 아이템 클릭이 안되요 ㅠㅠ 버튼 클릭리스너는 어댑터뷰에서 설정했구요!

<RelativeLayout
    android:descendantFocusability="blocksDescendants"
    android:id="@+id/listlayout"
    android:clickable="true"
    android:orientation="horizontal"
    android:layout_width="match_parent"
    android:layout_height="85dp">


    <Button
        android:id="@+id/progressend"
        android:text="end"
        android:focusableInTouchMode="false"
        android:focusable="false"
        android:clickable="false"
        android:background="@drawable/shape"
        android:textColor="@color/colorPrimary"
        android:layout_width="50dp"
        android:layout_height="wrap_content"
        android:layout_marginLeft="10dp"
        android:layout_alignTop="@+id/progressgo"
        android:layout_toRightOf="@+id/progressgo"
        android:layout_toEndOf="@+id/progressgo" />

    <Button
        android:text="confirm"
        android:focusableInTouchMode="false"
        android:focusable="false"
        android:clickable="false"
        android:id="@+id/progressgo"
        android:background="@drawable/shape_ok"
        android:textColor="@color/white"
        android:layout_width="50dp"
        android:layout_height="wrap_content"
        android:layout_alignTop="@+id/linearLayout"
        android:layout_toRightOf="@+id/linearLayout"
        android:layout_toEndOf="@+id/linearLayout" />

    <ProgressBar

        android:progressDrawable="@drawable/progressbar_custom"
        android:layout_marginTop="15dp"
        android:layout_marginLeft="60dp"
        android:layout_marginRight="10dp"
        android:max="100"
        android:id="@+id/progressbar"
        style="?android:attr/progressBarStyleHorizontal"
        android:layout_width="match_parent"
        android:layout_height="10dp"
        android:layout_below="@+id/linearLayout"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true" />

</RelativeLayout>

Adapter.java

  public void bindView(View view, final Context context, Cursor cursor) {

        final ProgressBar progressbar =(ProgressBar)view.findViewById(R.id.progressbar);
        final Button btn_go =(Button)view.findViewById(R.id.progressgo);
        final Button btn_end =(Button)view.findViewById(R.id.progressend);
        final RelativeLayout layout = (RelativeLayout)view.findViewById(R.id.listlayout);
        btn_go.setFocusable(false);
        btn_end.setFocusable(false);
        progressbar.setFocusable(false);
        final int  num =cursor.getInt(cursor.getColumnIndex("count"));



        btn_go.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

            }

        });

        btn_end.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {


            }
        });

        onContentChanged();

    }

fragment 탭에서 이런식으로 다른 프래그먼트에도 잘 붙었던 리스너 고대로 가져왔는데 안먹히네요 ㅠㅠ 뭐가 문제일까요

Tab2.java

   mListView = (ListView) view.findViewById(R.id.list);
   mListView.setEmptyView(view.findViewById(R.id.emptyView));
                                        dbmanager = new DBManager(getActivity());

 mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
    Toast.makeText(getView().getContext(), "리스트뷰 클릭리스너",
            Toast.LENGTH_SHORT).show();
    Context mContext = getActivity();
    cursor.moveToPosition(position);
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());

    LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(getActivity().LAYOUT_INFLATER_SERVICE);
    View layout = inflater.inflate(R.layout.tab2_dialog, null);

    TextView text = (TextView) layout.findViewById(R.id.dialog_name);
    TextView date = (TextView) layout.findViewById(R.id.dialog_date);
    TextView step = (TextView) layout.findViewById(R.id.dialog_step); (생략)`
  • (•́ ✖ •̀)
    알 수 없는 사용자

1 답변

  • 이제 ListView 대신에 RecyclerView를 쓰실 때가 된 겁니다 ㅎㅎ

    • (•́ ✖ •̀)
      알 수 없는 사용자

답변을 하려면 로그인이 필요합니다.

프로그래머스 커뮤니티는 개발자들을 위한 Q&A 서비스입니다. 로그인해야 답변을 작성하실 수 있습니다.

(ಠ_ಠ)
(ಠ‿ಠ)