Android Done button instead of Next

北战南征 提交于 2020-03-18 11:17:59

问题


I have a problem with the keyboard. I have a ListView with edit texts, and when the keyboard opens for the first time the Done button is displayed instead of Next. The problem is that I need to use adjustResize in the AndroidManifest.xml and the list is moved up when the keyboard is displayed, so I think this is why the keyboard is not working properly.

How can I solve this issue?


回答1:


Add android:imeOptions="actionDone" to the field where you need a done button on your keyboard. Add android:imeOptions="actionNext" to the field where you need a next button.

Also, ime has many option buttons like go, send, search, etc.




回答2:


In your layout, just set the XML attributes android:imeOptions="actionNext" for your EditText boxes in which you want next button to show and android:imeOptions="actionDone" for the last one.

To gain focus for your editText just do like this :

your_editText.setOnEditorActionListener(new OnEditorActionListener() 
{
    public boolean onEditorAction(TextView v, int actionId, KeyEvent event) 
    {
        if (actionId == EditorInfo.IME_ACTION_NEXT) 
        {
            your_editText.requestfocus(true);
            return true;
        }
        return false;
    }
});


来源:https://stackoverflow.com/questions/19110352/android-done-button-instead-of-next

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!