Android IME: showing a custom pop-up dialog (like Swype keyboard) which can enter text into the TextView

后端 未结 4 2190
刺人心
刺人心 2021-01-03 04:21

I\'m wondering how I can create a custom pop-up like the one in the screenshot below (borrowed from the Swype keyboard), where I can have a couple of buttons, which each com

4条回答
  •  情歌与酒
    2021-01-03 04:46

    Peace be upon those who follow the guidance,

    solution :

    AlertDialog dialog;
    
    //add this to your code
    dialog = builder.create();
    Window window = dialog.getWindow(); 
    
    WindowManager.LayoutParams lp = window.getAttributes();
    lp.token = mInputView.getWindowToken();
    lp.type = WindowManager.LayoutParams.TYPE_APPLICATION_ATTACHED_DIALOG;
    
    window.setAttributes(lp);
    window.addFlags(WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);
    //end addons
    
    dialog.show();
    

    ===== UPDATE 30.09.2015 mInputView its the general name of your keyboard class ..see

    @Override
        public View onCreateInputView() {
            mInputView =(MyKeyboardView) getLayoutInflater().inflate( R.layout.input, null);
    ....
    }
    

    More info : http://developer.android.com/guide/topics/text/creating-input-method.html

    good luck.

提交回复
热议问题