0

환경 설정의 아무 곳이나 클릭하여 값을 전환 할 수 있으므로 일반 CheckBoxPreference가 싫습니다. 어디서나 확인란을 클릭 만 허용하고 제목이나 요약은 무시할 수있는 사용자 지정 CheckBoxPreference를 만들려고합니다. 그러나, 나는 이것을 알아낼 수 없습니다.사용자 지정 CheckBoxPreference, 제목과 요약을 클릭하지 않도록 설정하는 방법

내 사용자 정의 CheckBoxPreference는 표준 양식과 같습니다

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:orientation="horizontal"> 

    <LinearLayout 
     android:id="@+id/talkButtonText" 
     android:layout_width="0dp" 
     android:layout_weight="85" 
     android:layout_height="fill_parent" 
     android:orientation="vertical"> 

    <TextView 
     android:id="@android:id/title" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentLeft="true" 
     android:layout_marginLeft="16dp" 
     android:layout_marginTop="5dp" 
     android:gravity="left" 
     android:textColor="#FFFFFF" 
     android:textSize="24sp" /> 

    <TextView 
     android:id="@android:id/summary" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentRight="true" 
     android:layout_below="@+android:id/title" 
     android:layout_marginLeft="16dp" 
     android:layout_marginTop="2dp" 
     android:gravity="left" 
     android:textColor="#c0c0c0" 
     android:textSize="14sp" /> 

</LinearLayout> 

<CheckBox 
    android:id="@+android:id/checkbox" 
    android:layout_width="0dp" 
    android:layout_weight="15" 
    android:layout_height="fill_parent" 
    android:gravity="center" 
    android:focusable="false" 
    android:clickable="false" 
    android:layout_alignParentRight="true" 
    android:layout_margin="16dp"/> 

</LinearLayout> 

현재 정확히 전체 폭에 아무 곳이나 클릭 표준 CheckBoxPreference 같은이 기능은 체크 박스 값을 변경합니다. 제목과 요약을 클릭하지 못하게하는 간단한 방법이 있습니까?

+0

해당 코드가 작동해야합니다. 무엇이 문제입니까? – diegoveloper

+0

요약/제목을 클릭하고 싶지는 않지만 확인란 만 클릭하면됩니다. 우연히 전체 영역을 칠 수있는 환경 설정을 선택하는 것은 너무 쉽습니다. –

+0

활동이나 단편 수업에 참여할 수 있습니까? – diegoveloper

답변

0

확인란에서 clickable/focusable = false를 제거하고 선형 레이아웃에 추가하십시오.

+0

이렇게하면 확인란이 환경 설정에 더 이상 연결되지 않으므로 환경 설정이 자동으로 저장되지 않습니다. clickable/focusable가 체크 박스에있을 때 저장 만하지만 물론 전체 텍스트 제목/요약도 클릭 할 수 있습니다. –

관련 문제