开发者

Android softkeyboard invoke using button click

May I know is it possible to invoke android softkeyboard or Softkeyboard sample provided in the Androidsdk sample by button click? As of now I could invoke the softkeyboard only on e开发者_开发技巧dit view control's focus.

As per the below suggestion I did the following modification, but still didnt worked: here is my code.. i got error on using getContentView() so I used "v".

private OnClickListener mKeypadbtnListener = new OnClickListener() { 
public void onClick(View v) { 
InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE); imm.showSoftInputFromInputMethod(v.getWindowToken(), 0);
}


You should try imm.showSoftInput(view, 0); instead of v.getwindowToken(). I think this will help you.


You can display the soft keyboard issuing the following:

InputMethodManager imm = (InputMethodManager) 
                     getSystemService(Context.INPUT_METHOD_SERVICE);
imm.showSoftInputFromInputMethod(getContentView().getWindowToken(), 0);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜