键盘按键之后预览是白板。求解决办法。有图说明 你加上这个看看能否看到预览数字keyboardView.setBackgroundColor(Color.RED); 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 @AMinfo设置背景不是上面预览的… 而是键盘本身后面的 那个小窗口API解释是 key feedback popup但是怎么设置其属性却没有说 是的。 因为第一次接触键盘,所以看了一个keyboardDemo之后按照Demo上面的方法写的一个布局不知道为什么,方法基本都一样,函数也就改了下响应内容。但是就是变成白板,感觉也没什么地方变动会引起这个问题 <?xml version="1.0" encoding="utf-8"?><Keyboard xmlns:android="http://schemas.android.com/apk/res/android" android:keyWidth="35dip" android:horizontalGap="0px" android:verticalGap="0px" android:keyHeight="32dip"> <Row> <Key android:codes="49" android:keyLabel="1" /> <Key android:codes="50" android:keyLabel="2" /> <Key android:codes="51" android:keyLabel="3" /> <Key android:codes="52" android:keyLabel="4" /> <Key android:codes="53" android:keyLabel="5" /> <Key android:codes="54" android:keyLabel="6" /> <Key android:codes="55" android:keyLabel="7" /> <Key android:codes="56" android:keyLabel="8" /> <Key android:codes="57" android:keyLabel="9" /> <Key android:codes="48" android:keyLabel="0" android:keyIcon="@drawable/ic_dialog_keyboard"/> <Key android:codes="46" android:keyLabel="." /> <Key android:codes="57419" android:keyLabel="+/-"/> <Key android:codes="-5" android:keyIcon="@drawable/sym_keyboard_delete" /> <Key android:codes="57421" android:keyEdgeFlags="right" android:isRepeatable="true" android:keyLabel="取消"/> <Key android:codes="-3" android:keyEdgeFlags="right" android:isRepeatable="true" android:keyLabel="完成" /> </Row></Keyboard>键盘布局 <RelativeLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:paddingLeft="5dp" android:paddingTop="5dp" android:layout_below="@+id/R_speed" > <android.inputmethodservice.KeyboardView android:id="@+id/keyboard_view" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:focusable="true" android:focusableInTouchMode="true" android:visibility="gone" /> </RelativeLayout>键盘在页面内的布局 View view = inflater.inflate(R.layout.item_system, null); llc.addView(view); X_speed = (EditText)view.findViewById(R.id.X_speed); X_speed.setInputType(InputType.TYPE_NULL); X_speed.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View arg0, MotionEvent arg1) { // TODO Auto-generated method stub ed = X_speed; showKeyboard(); return false; } });keyboardView = (KeyboardView)view.findViewById(R.id.keyboard_view); keyboardView.setKeyboard(new Keyboard(activity.getApplicationContext(), R.xml.keyboard)); keyboardView.setEnabled(true); keyboardView.setPreviewEnabled(false); keyboardView.setOnKeyboardActionListener(new OnKeyboardActionListener() { @Override public void onKey(int primaryCode, int[] keyCodes) { Editable editable = ed.getText(); int start = ed.getSelectionStart(); if (primaryCode == Keyboard.KEYCODE_CANCEL) { hideKeyboard(); } else if (primaryCode == Keyboard.KEYCODE_DELETE) { if (editable != null && editable.length() > 0) { editable.delete(start - 1, start); } } else if (primaryCode == 57419) { // go left ed.setText(String.valueOf(0-(Integer.valueOf(ed.getText().toString())))); ed.setSelection(ed.getText().toString().length());// } else if (primaryCode == 57421) { // go right if(proEdTxt!= null){ ed.setText(proEdTxt); hideKeyboard(); } } else { proEdTxt=ed.getText().toString(); editable.insert(start, Character.toString((char)primaryCode)); } }键盘java代码 代码不完整啊showKeyboard();和hideKeyboard();proEdTxt这个组件定义也没有。 这个只是设置键盘显示和隐藏的函数, 没什么特别的地方,和按下数字显示白板没关系。keyboardView.setPreviewEnabled(false);这个是不显示白板,直接点击按键之后就在EditText上面输入数字, 设置为true后就是白板 似乎回得太晚 不過給個解答在AndroidManifest.xml中加入theme<application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@android:style/Theme.Dialog" > 请问@AMinfo,你是用鼠标点击的还是使用实体键盘,我们需要使用实体键盘(外置的Hard keyboard)来实现点击键盘,出现key feedback popup 此贴对我帮助很大,让我明白原来这玩意不叫气泡不叫气球也不叫提示不叫hint不叫popup更不叫坑爹的balloon原来是叫preview!!! ScrollView中嵌入ViewPager,ViewPager的滑动出现问题 为什么我手动安装的APK无法运行 android数据库的查询问题 菜鸟问个基础问题 100分,进者有分 MB860 Android能否实现http透明代理 imageButton 报错空指针 如何给apk安装包配置动态参数 EditText设置监听器就会出错,麻烦网友看一下,感谢不尽 Android报错Class adrt.ADRT failed lock verification and will run slower. 报错 运行编写android程序时 Eclipse经常死掉 是怎么回事??
但是怎么设置其属性却没有说
不知道为什么,方法基本都一样,函数也就改了下响应内容。但是就是变成白板,感觉也没什么地方变动会引起这个问题
<?xml version="1.0" encoding="utf-8"?>
<Keyboard xmlns:android="http://schemas.android.com/apk/res/android"
android:keyWidth="35dip"
android:horizontalGap="0px"
android:verticalGap="0px"
android:keyHeight="32dip">
<Row>
<Key android:codes="49" android:keyLabel="1" />
<Key android:codes="50" android:keyLabel="2" />
<Key android:codes="51" android:keyLabel="3" />
<Key android:codes="52" android:keyLabel="4" />
<Key android:codes="53" android:keyLabel="5" />
<Key android:codes="54" android:keyLabel="6" />
<Key android:codes="55" android:keyLabel="7" />
<Key android:codes="56" android:keyLabel="8" />
<Key android:codes="57" android:keyLabel="9" />
<Key android:codes="48" android:keyLabel="0" android:keyIcon="@drawable/ic_dialog_keyboard"/>
<Key android:codes="46" android:keyLabel="." />
<Key android:codes="57419" android:keyLabel="+/-"/>
<Key android:codes="-5" android:keyIcon="@drawable/sym_keyboard_delete" />
<Key android:codes="57421"
android:keyEdgeFlags="right"
android:isRepeatable="true"
android:keyLabel="取消"/>
<Key android:codes="-3"
android:keyEdgeFlags="right"
android:isRepeatable="true"
android:keyLabel="完成" /> </Row>
</Keyboard>键盘布局
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingLeft="5dp"
android:paddingTop="5dp"
android:layout_below="@+id/R_speed" > <android.inputmethodservice.KeyboardView
android:id="@+id/keyboard_view"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:focusable="true"
android:focusableInTouchMode="true"
android:visibility="gone" />
</RelativeLayout>键盘在页面内的布局
View view = inflater.inflate(R.layout.item_system, null);
llc.addView(view);
X_speed = (EditText)view.findViewById(R.id.X_speed);
X_speed.setInputType(InputType.TYPE_NULL);
X_speed.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View arg0, MotionEvent arg1) {
// TODO Auto-generated method stub
ed = X_speed;
showKeyboard();
return false;
}
});
keyboardView = (KeyboardView)view.findViewById(R.id.keyboard_view);
keyboardView.setKeyboard(new Keyboard(activity.getApplicationContext(), R.xml.keyboard));
keyboardView.setEnabled(true);
keyboardView.setPreviewEnabled(false);
keyboardView.setOnKeyboardActionListener(new OnKeyboardActionListener() {
@Override
public void onKey(int primaryCode, int[] keyCodes) {
Editable editable = ed.getText();
int start = ed.getSelectionStart();
if (primaryCode == Keyboard.KEYCODE_CANCEL) {
hideKeyboard();
} else if (primaryCode == Keyboard.KEYCODE_DELETE) {
if (editable != null && editable.length() > 0) {
editable.delete(start - 1, start);
}
} else if (primaryCode == 57419) { // go left
ed.setText(String.valueOf(0-(Integer.valueOf(ed.getText().toString()))));
ed.setSelection(ed.getText().toString().length());//
} else if (primaryCode == 57421) { // go right
if(proEdTxt!= null){
ed.setText(proEdTxt);
hideKeyboard();
}
} else {
proEdTxt=ed.getText().toString();
editable.insert(start, Character.toString((char)primaryCode));
}
}键盘java代码
和按下数字显示白板没关系。
keyboardView.setPreviewEnabled(false);
这个是不显示白板,直接点击按键之后就在EditText上面输入数字, 设置为true后就是白板
在AndroidManifest.xml中加入theme
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@android:style/Theme.Dialog" >