开发者

How to detect if the keyboard is shown or not in Android?

开发者 https://www.devze.com 2023-03-26 06:15 出处:网络
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 sho

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();

}

}
0

精彩评论

暂无评论...
验证码 换一张
取 消