Android:在自定义编辑文本中触发softkeaboard
我想显示软键盘,但它不起作用。 这是我的代码:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
myTextView myTextView = new myTextView(this);
setContentView(myTextView);
}
public class myTextView extends EditText{
public boolean onTouchEvent(){
if(action == ACTION_DOWN){
super.onTouchEvent(event);
} }
当我触摸屏幕时,软键盘不会出现,但会出现alertDialog“编辑文本”,当您长时间触摸它们时,它会出现在正常的编辑文本上。 onCreate 中的这段附加代码没有任何影响:
InputMethodManager input = (InputMethodManager)
getSystemService(Context.INPUT_METHOD_SERVICE);
input.showSoftInput(myTextView, 0);
感谢帮助, Fr4gg0r
I want to show the softkeyboard, but it does not work.
Here is my code:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
myTextView myTextView = new myTextView(this);
setContentView(myTextView);
}
public class myTextView extends EditText{
public boolean onTouchEvent(){
if(action == ACTION_DOWN){
super.onTouchEvent(event);
} }
When i touch the screen, the softkeyboard does not appear, but the alertDialog "edit text" appears, which appears on normal edittexts when you long touch them.
This additional code in the onCreate has no affection:
InputMethodManager input = (InputMethodManager)
getSystemService(Context.INPUT_METHOD_SERVICE);
input.showSoftInput(myTextView, 0);
Thanks for help,
Fr4gg0r
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
试试这个 -
Try this -
我很抱歉这么晚才回答..
所以我使用以下命令尝试了您的代码:
myTextView.requestFocus();
但键盘不显示。
我必须更正我的文字:
在模拟器上,键盘不会显示,但在我的三星 Galaxy S 上,它会显示! :o
I'm very sorry this very late answer..
So I tried your code with the following command:
myTextView.requestFocus();
But the keyboard does not show up.
I have to correct my text:
On the emulator, the keyboard does not show up, but on my Samsung Galaxy S, it does! :o