I'm trying to create my own virtual keyboard since no default keyboard fits my needs.
I have created the layout (keyboard.xml), and I'd like to make my keyboard to appear in the bottom of the screen, as other keyboards do. I thought of using popupWindow.
I tried pw.showAtLocation(this.findViewById(R.id.mainLinearLayout), Gravity.BOTTOM, 0, 0)
, where mainLinearLayout is the id of the (root xml element) linearLayout 开发者_C百科of the currentActivity, but I get a "android.view.WindowManager$BadTokenException: Unable to add window -- token null is not valid; is your activity running?".
Any idea how to solve that ?
Thanks.
There is a way with an alertDialog. The alertDialog contains your xml. check my answer here :
android editText
And then for positionning your alerDialog see this thread :
Show AlertDialog in any position of the screen
精彩评论