Skip to content Skip to sidebar Skip to footer

Can't Manage To Requestfocus A Spinner

I've got an annoying issue with a screen. The screen consists of a bunch of Spinners one under the other, and then underneath the spinner, an EditText. The problem is that when the

Solution 1:

I had a similar problem, I solved by doing two things:

1) I set the Spinner object on top (Within the onCreate method) just to make sure that my code gets executed first. 2) I used the following:

Spinner s1 = (Spinner) findViewById(R.id.spinner1);
        s1.setFocusable(true);
        s1.setFocusableInTouchMode(true);

Let me know if this helps or you need any further help.


Solution 2:

From online documentation:

A view will not actually take focus if it is not focusable (isFocusable() returns false), or if it is focusable and it is not focusable in touch mode (isFocusableInTouchMode()) while the device is in touch mode.


Solution 3:

In my case,this worked out.

Spinner s1 = (Spinner) findViewById(R.id.spinner1);
s1.requestFocusFromTouch();
s1.performClick();

Post a Comment for "Can't Manage To Requestfocus A Spinner"