0

I'd like to recreate the CheckedTextView's functionality using my own custom views so I can have two TextViews on the left with a CheckBox on the right, centered vertically between the two TextViews. I have the Layout working for it, which I will include below. I also have it so that when you click on the outer LinearLayout (LinearLayout1) it will pass that click to the checkbox. The only thing that I can't figure out is when you press down on a checkbox it briefly highlights the checkbox (in yellow on my device) before marking it checked. I'd like to have it do the same if you touch anywhere on the outer LinearLayout, but I don't know where I'd need to hook in to make that happen.

Here is my layout.xml

<LinearLayout
    android:orientation="horizontal"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:id="@+id/LinearLayout1">
    <LinearLayout
        android:orientation="vertical"
        android:layout_height="wrap_content"
        android:layout_width="0dip"
        android:layout_weight="1"
        android:id="@+id/LinearLayout2">
        <TextView
            android:id="@+id/FieldValueTextView"
            android:text="Value"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:textAppearance="?android:attr/textAppearanceMedium" />
        <TextView
            android:id="@+id/FieldLabelTextView"
            android:text="Label"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:textAppearance="?android:attr/textAppearanceSmall" />
    </LinearLayout>
    <CheckBox
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:layout_toRightOf="@id/LinearLayout2"
        android:id="@+id/CheckBox"
        android:gravity="center_vertical" />
</LinearLayout>

Thanks,
Dan

4

1 に答える 1

0

私が経験した問題は、チェックボックスと2つのTextViewに次のandroid:focusable = "false"を配置することで解決されました。これにより、ListViewをクリックすると、内部ビューではなくフォーカスが取得されます。

それが他の誰かを助けることを願っています。

于 2012-07-26T08:38:25.027 に答える