Android PopupWindow dismiss issue
<p>I have read many forums about this common issue but not able to solve it in my application.
In my android app I need to show a popup window in which there is a form having edit text and save button. When user clicks on save button the popup window should refreshed. I have tried the dismiss method but :-(</p>

<p>Javacode:</p>

<pre><code>            LayoutInflater inflater = (LayoutInflater) ListActivity.this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        final View popUp_layout = inflater.inflate(R.layout.popup_example,(ViewGroup) findViewById(R.id.popup_form_add_quote));
        final PopupWindow popUp = new PopupWindow(inflater.inflate(R.layout.popup_example, null, false), 430, 300, true);
        popUp.setBackgroundDrawable(new BitmapDrawable());
        popUp.setOutsideTouchable(true);
 //     popUp.showAtLocation(popUp_layout, Gravity.CENTER, 10, 10);
        Button save_Button = (Button) popUp_layout.findViewById(R.id.save_quote_button);
        AlertDialog.Builder builder = new AlertDialog.Builder(this).setView(popUp_layout); 
        AlertDialog alertDialog = builder.create();
        alertDialog.show();
        save_Button = (Button) alertDialog.findViewById(R.id.save_quote_button);
        if (save_Button != null) {
            save_Button.setOnClickListener(new OnClickListener() {

                @Override
                public void onClick(View v) {
                    System.out.println("Save button clicked.");
                        popUp.dismiss();

                }
            });
        }
</code></pre>

<p><strong>xml/widget_info.xml</strong></p>

<pre><code>&lt;appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
android:initialLayout="@layout/widget_layout"
android:minHeight="82dp"
android:minWidth="246dp"
android:updatePeriodMillis="1000" &gt;
</code></pre>

<p></p>

<p><strong>drawable-mdpi/myshape.xml</strong></p>

<pre><code>&lt;shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" &gt;
&lt;stroke android:width="2dp" vandroid:color="#FFFFFFFF" /&gt;

&lt;gradient android:angle="225" android:endColor="#DD2ECCFA" android:startColor="#DD000000" /&gt;

&lt;corners android:bottomLeftRadius="7dp" android:bottomRightRadius="7dp" android:topLeftRadius="7dp" android:topRightRadius="7dp" /&gt;
</code></pre>

<p> </p>

<p><strong>layout/popup_example.xml</strong></p>

<pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/popup_form_add_quote"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#C0CAE0"
android:orientation="vertical"
android:padding="10dip" &gt;

&lt;TextView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_marginTop="10dip"
    android:text="Quote" /&gt;

&lt;EditText
    android:id="@+id/quote_text"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:gravity="left"
    android:layout_weight="0.80"
    android:ems="10"
    android:inputType="textMultiLine"
    android:lines="4"
    android:maxLines="4" &gt;

    &lt;requestFocus /&gt;
&lt;/EditText&gt;

&lt;CheckBox
    android:id="@+id/quote_status_checkbox"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Enable/Disable" /&gt;

&lt;Button
    android:id="@+id/save_quote_button"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center_horizontal"
    android:text="Save" /&gt;
</code></pre>

<p></p>
