You can make a view clickable, as a button, by adding the android:onClick attribute in the XML layout.
clickable seems to be useful when you need a view to consume clicks so that they do not go to views beneath the top view. For example, I have a FrameLayout that I display over an underlying RelativeLayout at certain times. When the user would click on an underlying EditText the focus would shift to that EditText .
2 Answers. Show activity on this post. Remove the setOnClickListener since you already specify in your view that the onclick function for the button is onClick . To avoid confusion rename your button android:onClick="onClick" , like android:onClick="imageButtonOnClick" .
I've got a linear layout that i have set true to be clikable + focus, But the problem is there is no focus displayed when clicked. How can i get the focus to be displayed.
Heres my code
<LinearLayout
android:id="@+id/linear_tv_layout"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:clickable="true"
android:focusable="true"
android:paddingBottom="7px">
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With