开发者

Set focus on button behind soft keyboard

I'm having trouble with this and, from the research I have done, I think it may be a reported bug in 2.1. I have a page with two edittext fields which are numeric. I can click on the first and the soft keyboard pops up ... 开发者_StackOverflow社区when I press 'next' the focus goes to the next edittext as required.

Now, I enter a number here and press 'next' and, although the soft keyboard says that next has been pressed, my call to set the focus to my own next button (which is actually hidden by the soft keyboard) doesn't happen.

I have tried to close the keyboard in code but again, nothing works.

As always, any advice will be gratefully received.


I'm not sure if this is a bug or not... the Next option that appears in soft keyboard input should only set focus to the next view that is actually an editable field, therefore would not move to a button.

Devices that actually have hard keyboards and arrow buttons that move focus should work... but as far as I know this is normal behavior. The user would have to back-press to close the input and then operate your own next button.

Interestingly enough... if there is not an editable view coming next in the hierarchy... my soft input usually changes from "Next" to "Done" so I'm not sure why you'd even have a "Next" option that that point.


I thank Maximus for his answer which pointed me in the right direction.

It all boils down to the dreaded 'Cut and Paste' where we tend not to examine the code we pasted. As I said above, I have two edit fields and I have this xml code in the first:

 <EditText
        android:id="@+id/editnum1"
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:imeOptions="actionNext"
        android:inputType="number"
        android:digits="1234567890./-+"
        android:maxLength="12"
        android:textSize="18sp">
      </EditText>

Notice the line 'android:imeOptions="actionNext" ' which tells the keyboard to move to the next edit field. Of course, I (accidentally) cut and pasted this code for the second button and so it was thinking there must be another edit field to go to.

Having removed this line in the xml the soft keyboard disappears as requested.

Thanks again,

Alan ...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜