0

I have changed from toggleSoftInput to showSoftInput but no use

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);            
        }
Faizan
  • 9
  • 1

2 Answers2

0
button1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
    Toast.makeText(MainActivity.this,"Button Clicked", Toast.LENGTH_LONG).show();
    InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(MainActivity.INPUT_METHOD_SERVICE);
    inputMethodManager.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
}
});

this code work fine.. no need to change in that code..

Amey Bawiskar
  • 361
  • 1
  • 3
  • 17
  • `SubActionButton Btn1 = itemBuilder.setContentView(icon1).build(); Btn1.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Toast.makeText(MainActivity.this,"Button Clicked", Toast.LENGTH_SHORT).show(); InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(MainActivity.INPUT_METHOD_SERVICE); inputMethodManager.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);}});` using https://github.com/oguzbilgener/CircularFloatingActionMenu – Faizan Dec 24 '15 at 10:19
0

in onClick of your button hide keyboard first and then show toast next

hideKeyboard();
Toast.makeText(MainActivity.this,"Button Clicked",Toast.LENGTH_LONG).show();

write hideKeyboard method as follows

  InputMethodManager inputManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
  inputManager.hideSoftInputFromWindow(view.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
Anbarasu Chinna
  • 975
  • 9
  • 28
  • i actually want the keyboard to be displayed too... I have added toast just for reference to check if the onClick is working... The toast pops up means the onClick is working but the keyboard doesnt show up.. thats the issue.. – Faizan Dec 24 '15 at 09:42
  • try this, go Menu-->Setting -->Apps-->Select your app --> in your app info there is a checkbox called "Show Notification". Enable this to show your app Toast,Disable this to Hide It. – Anbarasu Chinna Dec 28 '15 at 06:22