How to detect if the keyboard is shown or not in Android?
Is it possible to detect if the keyboard is shown in Android? I tried this answer: How to check visibility of software keyboard in Android? but nothing happens. I need to know when the keyboard is shown for moving some EditText to the front of the screen开发者_JS百科. Or,..can I do this otherwise?
Its possible, but there is no direct API call to detect this. For workaround see: How to check visibility of software keyboard in Android?
Check this out:
public class myTextEdit extends TextEdit{
public InputConnection onCreateInputConnection (EditorInfo outAttrs){
InputConnection ic = super.onCreateInputConnection(outAttrs);
//Do here whatever you want like notifying parent or Activity
//To notify activity Give handle
//EXAMPLE:
public myActivity parent;
public setActivity(Activity a){
parent = a;
} //in this way you can tell activity : parent.keyboardShown();
}
}
精彩评论