마스터Q&A 안드로이드는 안드로이드 개발자들의 질문과 답변을 위한 지식 커뮤니티 사이트입니다. 안드로이드펍에서 운영하고 있습니다. [사용법, 운영진]

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

0 추천

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

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

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="match_parent"
    android:descendantFocusability="blocksDescendants"
    android:layout_height="match_parent"
    android:weightSum="1">

    <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>


</LinearLayout>

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

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,130 포인트) 님이 2016년 11월 30일 질문

1개의 답변

0 추천

안녕하세요

커스텀 어댑터에 버튼 클릭 이벤트 넣으셨죠?

 focusable:"false" << 이거빼시면 버튼 이벤트랑 리스트뷰 아이템 클릭 이벤트 다 됩니다.

수고하세요!

 

히로시 (10,800 포인트) 님이 2016년 12월 1일 답변
...