Hossein
Hossein

Reputation: 973

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.

Upvotes: 4

Views: 4124

Answers (2)

Hossein
Hossein

Reputation: 973

I just set setBackgroundDrawable of PopupWindow. Everything seems be OK! I'm in consternation!!

Upvotes: 2

Ali Imran
Ali Imran

Reputation: 9217

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.

Upvotes: 10

Related Questions