I\'m having trouble with the on screen keyboard. I have an activity with an EditText
which shows the keyboard, and a button to go to a second activity. The second a
you can use like this also:
InputMethodManager imm;
Write below line in onCreate() Method:
imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
And this line is in onclick of button:
imm.hideSoftInputFromWindow(arg0.getWindowToken(), 0);
Example:
public class FirstActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
findViewById(R.id.button1).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
imm.hideSoftInputFromWindow(arg0.getWindowToken(), 0);
Intent intent = new Intent(FirstActivity.this, SecondActivity.class);
startActivity(intent);
}
});
}
}