Note that there are some explanatory texts on larger screens.

plurals
  1. POReturn a value from Popup Window
    primarykey
    data
    text
    <p>I have popup window class like the following.</p> <pre><code>public class Popup extends PopupWindow { Context context; EditText et_bankname, et_banknumber; String bank_name, account_number; public Popup(Context ctx) { super(ctx); context = ctx; setContentView(LayoutInflater.from(context).inflate(R.layout.bank_details, null)); setHeight(WindowManager.LayoutParams.WRAP_CONTENT); setWidth(WindowManager.LayoutParams.WRAP_CONTENT); View popupView = getContentView(); setFocusable(true); Button btn_close = (Button) popupView.findViewById(R.id.popupClose); Button btn_submit = (Button) popupView.findViewById(R.id.popupSave); et_bankname = (EditText) popupView.findViewById(R.id.bank_name); et_banknumber = (EditText) popupView.findViewById(R.id.bankacc_no); btn_submit.setOnClickListener(new OnClickListener() { public void onClick(View v) { bank_name = et_bankname.getText().toString(); account_number = et_banknumber.getText().toString(); if (!bank_name.equals("") &amp;&amp; !account_number.equals("")) { Toast t1 = Toast.makeText(context,bank_name + " "+account_number , Toast.LENGTH_SHORT); t1.setGravity(Gravity.TOP, 0, 100); t1.show(); dismiss(); } else { Toast t1 = Toast.makeText(context, "Please provide valid details", Toast.LENGTH_SHORT); t1.setGravity(Gravity.TOP, 0, 100); t1.show(); } } }); } public void show(View v) { showAtLocation(v, Gravity.CENTER, 0, 0); } } </code></pre> <p>I will access this popup in my activity by</p> <pre><code>Popup popup = new Popup(getBaseContext()); popup.show(arg1); </code></pre> <p>This works perfectly. But I want to know when this popup window gets dismissed. for this purpose now I am using <code>Thread</code> concept like following.</p> <pre><code>if (isPopupShowing) { Thread thread = new Thread() { @Override public void run() { while (isPopupShowing) { if (!popup.isShowing()) { isPopupShowing = false; MainActivity.this.runOnUiThread(new Runnable() { public void run() { loadDSP(type); } }); } } } }; thread.start(); } </code></pre> <p>But this thread will run continuesly until the popup window gets dismissed. So I feel it is better to replace this solution by any other way. </p> <p>What I want? Just intimate to my activity like "popup is closed" when popup is dismissed. </p> <p>Why I am use this way? I will use this popup window in three activty. That is why I am create a separate class for popup window.</p> <p>Any help will be highly appriciated.</p> <p>Thank you.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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