Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make custom view focusable [duplicate]

How can I make a custom View subclass focusable by touching it? I'm calling

setFocusable(true);
setFocusableInTouchMode(true);

from the constructor, and an EditText before my control can pass focus to it ("Next" appears instead of "Done" in the soft keyboard), but I need to be able to focus it by tapping on it.

I've seen the solution of setting android:focusable="true" and android:focusableInTouchMode="true" in the layout XML where it is used, but even that doesn't work.

like image 749
solarshado Avatar asked Jul 08 '14 17:07

solarshado


1 Answers

Solved: needed to call setClickable(true) too.

like image 109
solarshado Avatar answered Oct 14 '22 08:10

solarshado