Kindle Fire键盘按钮

3

我的应用中

           <EditText                    
                android:id="@+id/task_buy_edit_mass_editText1"
                android:minWidth="100dip"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"                    
                android:inputType="numberDecimal"
                android:imeOptions="actionDone" >

            </EditText>

问题在于,在我的Kindle Fire上,当用户想要编辑EditText时出现的键盘没有“完成”按钮,只有一个隐藏软键盘的按钮。 enter image description here 如果我可以截取上面截图中突出显示的“隐藏键盘”按钮,那就不是问题了。然而,它似乎不能触发我附加到EditTextOnEditorActionListener,所以除了在我的实际布局中拥有自己的“完成”按钮以将焦点从EditText中移开、隐藏键盘并使任何由更改而导致的更改生效之外,我还有点困惑该怎么办。
有没有办法截取“隐藏键盘”按钮,或者有其他解决方法?
顺便说一下,我的应用程序中其他地方有一个普通的EditText视图,它没有imeOptions,也没有指定inputType,并且具有返回键。
以下是参考代码的其余部分:
        editText.setOnEditorActionListener(new OnEditorActionListener(){

            @Override
            public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
                if(actionId==EditorInfo.IME_ACTION_DONE || actionId==EditorInfo.IME_ACTION_NEXT || actionId==EditorInfo.IME_NULL || event.getKeyCode()==KeyEvent.FLAG_EDITOR_ACTION || event.getKeyCode()==KeyEvent.KEYCODE_ENTER){
                    closeKeyboard(v, done_button);              
                    return true;
                }
                return false;
            }});

            // set done button for keyboards without correct IME options
            final EditText finalEditText = editText;

            editText.setOnTouchListener(new OnTouchListener(){

                @Override
                public boolean onTouch(View v, MotionEvent event) {                     
                    done_button.setOnClickListener(new OnClickListener(){
                        @Override
                        public void onClick(View v) {                               
                            closeKeyboard(finalEditText, v);
                        }});
                    done_button.setVisibility(View.VISIBLE);
                    return false;
                }                   
            });

.

        private void closeKeyboard(TextView v, View buttonv){
                demand.setAmount(Double.parseDouble((v.getText().toString()))); // update the game

                // close keyboard
                InputMethodManager inputManager = (InputMethodManager) v.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);                       
                inputManager.hideSoftInputFromWindow(v.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);                       
                v.clearFocus();
                buttonv.setVisibility(View.GONE);
        }

StackOverflow是用于编程问题的,而您并没有提出问题。 IME不必遵守android:imeOptions =“actionDone”,因此尽管您可能在Fire上看到这个问题,但问题比那更普遍。 - CommonsWare
我知道。我正在寻找Kindle Fire的解决方案。我编辑了我的答案,以使我的问题更清晰明确。 - James Coote
2
你可以尝试在EditText中添加android:inputType="textMultiLine"和android:singleLine="true",但是我发现这会在新的Jelly Bean设备上引起问题。 - James Wald
1个回答

1

android:inputType="textMultiLine"android:singleLine="true",如@James Wald所指示的那样起作用。

编辑: 执行上述操作将使EditText多行。相反,在所有设备上,android:imeOptions="actionGo" 对我的目的起作用(据我所知)。


android:imeOptions="actionGo" 更为合适,请使用 :) - James Wald

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接