我的 Android 应用中有自定义 键盘.xml中描述的布局是这样的
I have custom keyboard in my app for Android. It's layout described in xml like this
<Keyboard xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"">
<Row>
<Key android:keyLabel="F1" android:keyOutputText="F1"/>
<Key android:keyLabel="F2" android:keyOutputText="F2"/>
<Key android:keyLabel="F3" android:keyOutputText="F3"/>
...
所以,我很想知道如何禁用,例如f1"键~让它变灰且不可触摸.这里有一些类似的问题,但都是关于默认软知识库的.
So, i'm insteresting how i can disable, for example 'f1' key ~ make it grey and untouchable. There are some similar questions here, but all about default soft-KB.
我知道我可以像这样遍历键
I know I can iterate through keys like this
for (Keyboard.Key key : myKeyboard.getKeys())
但它看起来像 Keyboard.Key 类的对象对按键外观的任何变化都无用.
but it's look like objects of Keyboard.Key class are useless for any changes in key's look.
UPD:我没有找到解决方案.我手动实现了键盘——大的相对布局、常用按钮和自定义按钮,一切都很好.顺便说一句 - 自定义键盘至少更漂亮.只需从 droid 4+ 复制资源 - 您将在每个平台上获得漂亮的现代透明按钮和透明布局.
UPD: I did not found solution. I implemented keyboard manually - big relative layout, common buttons and custom buttons and everything fine. By the way - custom keyboard at least more beautiful. Just copy resources from droid 4+ - and you'll get nice modern transparent buttons and transparent layout on every platform.
通常键盘只有在编辑时才可见,因此您可以通过对象捕获编辑.如果它是一个 editText 框,那么您可以添加一个侦听器,然后您可以禁用对编辑文本的任何响应.我不确定这是否对您有用,但至少您可以捕获任何不需要的输入.
Usually the keyboard is only visible if you are editing something, so you can trap the edits via the object. If its an editText box then you can add a listener and then you could disable any response to the edit text. I'm not sure if this is useful to you but at least you can trap any unwanted input.
// add a keylistener to keep track user input
editText.setOnKeyListener(new View.OnKeyListener() {
public boolean onKey(View v, int keyCode, KeyEvent event) {
// if keydown and "enter" is pressed
if ((event.getAction() == KeyEvent.ACTION_DOWN)
&& (keyCode == KeyEvent.KEYCODE_ENTER)) {
// do some thing or nothing
return true;
}
return false;
}
});
这篇关于在Android中禁用自定义键盘上的一键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!