长按按键时,Android软键盘弹出视图 [英] Android softkeyboard popup view on key long press
问题描述
我正在开发Android软键盘:
I am developing Android soft keyboard:
public class CustomKeyboard extends Keyboard{...}
public class CustomKeyboardView extends KeyboardView{...}
public class CustomKeyboardIME extends InputMethodService implements KeyboardView.OnKeyboardActionListener{...}
在某些键上,我有popupKeyboard和popupCharacters:
On some keys, I have popupKeyboard and popupCharacters:
<Key android:codes="144" android:keyLabel="0" android:popupKeyboard="@xml/key_popup" android:popupCharacters=")" android:keyEdgeFlags="right"/>
xml/key_popup.xml:
xml/key_popup.xml:
<Keyboard xmlns:android="http://schemas.android.com/apk/res/android"
android:keyWidth="10%p"
android:horizontalGap="0px"
android:verticalGap="0px"
android:keyHeight="@dimen/key_height" >
但是当我长按"0"键时,弹出带有)"的窗口,但是一直停留到我按下"X"按钮或)"字符为止.
But when I longPress on "0" key popup with ")" shows, but it stays there until I press "X" button or ")" character.
并且我希望仅在手指保持打开状态下将其打开.在iPhone键盘上类似的东西:
And I want it to be opened only while I am holding a finger on. Something like on iPhone keyboard:
任何人都可以帮忙吗?
谢谢!
推荐答案
在这种情况下,我认为您需要使用PopupWindow或Dialog创建自己的弹出窗口.
I think you will need to create your own popup in this case, using PopupWindow or Dialog.
然后进入键盘并覆盖onRelease方法,如下所示:
then you go into your keyboard and overwrite your onRelease method, like this:
@Override
public void onRelease(int primaryCode) {
myPopupWindow.dismiss();
}
要为键盘创建自己的popupWindow,请参见以下线程: 长按Android自定义键盘弹出键盘
To make your own popupWindow for keyboard see this thread: Android custom keyboard popup keyboard on long press
这篇关于长按按键时,Android软键盘弹出视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!