Make custom view focusable

android, custom-controls

Solution

Solved: needed to call `setClickable(true)` too.

Problem

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.

Original source

Related problems