Note that there are some explanatory texts on larger screens.

plurals
  1. POPopup Window Destroy on screen orientation
    text
    copied!<p>I am using the <code>PopupWindow</code>. I am facing one problem that <code>PopupWindow</code> destroy when screen orientation change.</p> <p>I need to it should not destroy on screen orientation change.</p> <p>I set this for this activity.</p> <pre><code>&lt;activity android:name=".MainPageActivity" android:configChanges="orientation|keyboardHidden" android:label="@string/app_name" android:windowSoftInputMode="adjustPan" &gt; &lt;intent-filter&gt; &lt;action android:name="android.intent.action.MAIN" /&gt; &lt;category android:name="android.intent.category.LAUNCHER" /&gt; &lt;/intent-filter&gt; &lt;/activity&gt; </code></pre> <p>Code</p> <pre><code>/** * Pop up Window */ private void initatePopUpWindow() { try { LayoutInflater layoutInflator = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); View layout = layoutInflator.inflate(R.layout.popup_new_quote, (ViewGroup) findViewById(R.id.popupNewQuote)); displayMetrics = context.getResources().getDisplayMetrics(); display = ((WindowManager) this.getSystemService(WINDOW_SERVICE)).getDefaultDisplay(); if(!(display.getOrientation() == Configuration.ORIENTATION_LANDSCAPE || display.getOrientation() == Configuration.ORIENTATION_UNDEFINED)) { popupWindow = new PopupWindow(layout, displayMetrics.widthPixels, (int)(displayMetrics.heightPixels * .40f), true); } else popupWindow = new PopupWindow(layout, displayMetrics.widthPixels / 2, displayMetrics.heightPixels / 2, true); popupWindow.setAnimationStyle(R.style.AnimationPopup); popupWindow.showAtLocation(layout, Gravity.CENTER, 0, 0); //New Quote and Quote Name TextView ((TextView)layout.findViewById(R.id.newQuoteTextView)).setTypeface(typeFace); ((TextView)layout.findViewById(R.id.quoteNameTextView)).setTypeface(typeFace); //Quote Name final EditText quoteName = (EditText)layout.findViewById(R.id.quoteNameEditText); layout.findViewById(R.id.cancelButton).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { //Dismiss the pop up window popupWindow.dismiss(); } }); layout.findViewById(R.id.saveButton).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if(!quoteName.getText().toString().equals("")) { Quote quote = new Quote(); quote.setQuoteName(quoteName.getText().toString().trim()); quote.setQuotePercentComplete("0"); quote.setQuoteCreateDate(Helper.getCurrentDate()); DatabaseHandler db = new DatabaseHandler(context); if(!db.isRecordExist(quoteName.getText().toString())) { long insertId = db.insertQuote(quote); db.close(); //Start the activity Intent intent = new Intent(context, NewQuoteTabActivity.class); intent.putExtra("create_new_quote", true); intent.putExtra("quote_name", quoteName.getText().toString()); intent.putExtra("id", insertId); startActivity(intent); } else Toast.makeText(context, getString(R.string.quote_duplicate), Toast.LENGTH_LONG).show(); } else Toast.makeText(context, context.getString(R.string.enter_quote_name), Toast.LENGTH_LONG).show(); } }); //Save Button and Cancel Button ((Button)layout.findViewById(R.id.saveButton)).setTypeface(typeFace); ((Button)layout.findViewById(R.id.cancelButton)).setTypeface(typeFace); } catch(Exception e) { Log.v(GlobalVars.TAG, "Exeption at::" + e.getMessage()); } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload