0
我有一个edittext视图,其默认文本值如'输入值'。当用户触摸edittext时,我想清除edittext的值并向用户显示虚拟键盘。虚拟键盘问题
我这样做,它仍然无法正常工作。任何人都可以告诉我如何做到这一点?
@Override
public boolean onTouch(View arg0, MotionEvent arg1) {
// TODO Auto-generated method stub
edtsearch.setText("");
//((InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE)).showSoftInput(edtsearch, 0);
InputMethodManager mgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
mgr.showSoftInput(edtsearch, InputMethodManager.SHOW_IMPLICIT);
return true;
}
上面的代码没有显示键盘。任何人都可以告诉我如何清除数值并向用户显示键盘吗?
即使我使用android:提示键盘时只有点击它清除值。如果用户触摸编辑文本框,则需要清除该值并将键盘显示给用户。
@mohan这是[提示属性]的文档(http://developer.android.com/reference/android/widget/TextView.html#attr_android:hint) – 2011-02-01 16:25:29