How to add a clear button in a popup window
<p>I am new to android development. I have created a popup window which is being called on a button click from the main activity class. I have some Edit text field on my pop window. can i clear all these edit text field on the pop up window through a button click? if yes then how? Thanks in advance!! 
Below is what i am trying but it is giving null point exception.</p>

<pre><code> public void initatePopupWindow(View view)
{
    try
    {
        LayoutInflater inflater=(LayoutInflater)  ContactdetailsActivity.this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View layout=inflater.inflate(R.layout.popupwindow,(ViewGroup)findViewById(R.id.popuplayout));
        pw = new PopupWindow(layout, 500, 500, true);
        pw.showAtLocation(layout, Gravity.CENTER, 0, 0);
        Button b1=(Button)layout.findViewById(R.id.cancel);
       b1.setOnClickListener(cancel_button_click_listener);   
       Button b2=(Button)layout.findViewById(R.id.clear);

       b2.setOnClickListener(clear_fields);


    }
    catch (Exception e)
    {

    }
}
    private OnClickListener clear_fields= new OnClickListener()
    {
        public void onClick(View v)
        {

        ViewGroup group= (ViewGroup)findViewById(R.id.popuplayout);
            for(int i=0,count=getChildCount(); i&lt;count; ++i)
            {
                View v1= group.getChildAt(i);
                if(v1 instanceof EditText)
                {
                    ((EditText)v1).setText("");
                }
                if(v1 instanceof ViewGroup &amp;&amp; (((ViewGroup)v1).getChildCount() &gt; 0))
                    onClick((ViewGroup)v1);
            }
        }
    };
    private OnClickListener cancel_button_click_listener=new OnClickListener()
    {
        public void onClick(View v)
        {
        pw.dismiss();
        }
    };

}
</code></pre>
