Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Focus on EditText in a Popup Window goes the activity to sleep

I place an EditText on a PopupWindow in my android project. When set PopupWindow.setFocusable to the false, the soft keyboard will not be show. And when set PopupWindow.setFocusable to the true, the EditText is focused and activity go to sleep! Other item on the pop up window works, but back button on the phone and clicking outside the pop up does not close it. Thanks in advance.

like image 259
Hossein Avatar asked Dec 16 '22 16:12

Hossein


1 Answers

Some code from my project may help

        LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        PopupWindow  share_popup = new PopupWindow(inflater.inflate(R.layout.share_dropdown, null, false), 162, LinearLayout.LayoutParams.WRAP_CONTENT, true);
        share_popup.setOutsideTouchable(true);
        share_popup.setTouchable(true);
        share_popup.setFocusable(true);
        Drawable image_saved = getResources().getDrawable(R.drawable.dummy_bg);
        share_popup.setBackgroundDrawable(image_saved);

where this R.drawable.dummy_bg is a transparent image.

like image 197
Ali Imran Avatar answered May 08 '23 15:05

Ali Imran