Android 这是我的onClick方法代码。祝酒词已显示,但键盘未显示

Android 这是我的onClick方法代码。祝酒词已显示,但键盘未显示,android,keyboard,Android,Keyboard,我已从toggleSoftInput更改为showSoftInput,但没有使用 public void onClick(View v) { Toast.makeText(MainActivity.this,"Button Clicked",Toast.LENGTH_LONG).show(); InputMethodManager imm = (InputMethodManager) getSystemService(MainActivity.INP

我已从toggleSoftInput更改为showSoftInput,但没有使用

public void onClick(View v) {
            Toast.makeText(MainActivity.this,"Button Clicked",Toast.LENGTH_LONG).show();
           InputMethodManager imm = (InputMethodManager) getSystemService(MainActivity.INPUT_METHOD_SERVICE);
           imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);            
        }
这个代码很好用。。
无需更改该代码。

单击按钮,首先隐藏键盘,然后显示下一步

hideKeyboard();
Toast.makeText(MainActivity.this,"Button Clicked",Toast.LENGTH_LONG).show();
编写隐藏板方法,如下所示

  InputMethodManager inputManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
  inputManager.hideSoftInputFromWindow(view.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);

访问此我实际上希望键盘也显示出来。。。我添加toast只是为了检查onClick是否有效。。。祝酒词弹出表示onClick正在工作,但键盘没有显示。。这就是问题所在。试试这个,转到菜单-->设置-->应用-->选择应用-->在应用信息中有一个称为“显示通知”的复选框。启用此选项可显示应用程序土司,禁用此选项可隐藏应用程序土司。
SubActionButton Btn1=itemBuilder.setContentView(icon1.build();Btn1.setOnClickListener(new View.OnClickListener(){@Override public void onClick(View v){Toast.makeText(MainActivity.this,“点击”按钮,Toast.LENGTH_SHORT.show();InputMethodManager InputMethodManager=(InputMethodManager)getSystemService(MainActivity.INPUT_方法_服务);inputMethodManager.toggleSoftInput(inputMethodManager.SHOW_FORCED,0);}});
使用
  InputMethodManager inputManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
  inputManager.hideSoftInputFromWindow(view.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);