user4151797
user4151797

Reputation: 75

How can I give a android checkbox item two onClick events?

Im creating a simple bucketlist app. I want to sort when a user clicks on the checkbox itself but if they click on the text next to the checkbox, I want to open up an edit activity. How can I have these two onclick events for one checkbox? I am using a recyclerview if that changes anything.

<LinearLayout
    android:layout_height="fill_parent"
    android:layout_width="wrap_content"
    android:id="@+id/linearLayout1"
    android:orientation="vertical"
    android:layout_weight="1"
    >
    <CheckBox
        android:text="Place_holder Name"
        android:id="@+id/bucket_name"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1">

    </CheckBox> </LinearLayout>

Upvotes: 0

Views: 35

Answers (1)

Alex
Alex

Reputation: 779

I would remove the text from the checkbox and place a textview right next to it and put the text in the textview. This way you can easy distinguish between two types(on the checkbox and on the text) of clicks, because they would be clicks on different views.

Upvotes: 1

Related Questions