I have an android app that works fine, apart from that in one part of it the keyboard – although opened with the following code – does not appear:
View.OnFocusChangeListener vof = new View.OnFocusChangeListener() {
public void onFocusChange(View v, boolean hasFocus) {
if (hasFocus) {
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
}
}
};
// ...
final TextView input = (TextView) findViewById(R.id.answer);
input.setOnFocusChangeListener(vof);
input.requestFocus();
Everything I could find on other help pages only came up with this solution, which did not work when I tried to use it on my Samsung Galaxy S2.
I found the problem – the XML layout asked for the focus before I set the listener so that onFocusChange was never called:
When I removed the <requestFocus /> part it worked as I wanted it to.