Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8126005
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T07:00:34+00:00 2026-06-06T07:00:34+00:00

I am new to android development. I have created a popup window which is

  • 0

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.

 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<count; ++i)
            {
                View v1= group.getChildAt(i);
                if(v1 instanceof EditText)
                {
                    ((EditText)v1).setText("");
                }
                if(v1 instanceof ViewGroup && (((ViewGroup)v1).getChildCount() > 0))
                    onClick((ViewGroup)v1);
            }
        }
    };
    private OnClickListener cancel_button_click_listener=new OnClickListener()
    {
        public void onClick(View v)
        {
        pw.dismiss();
        }
    };

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T07:00:36+00:00Added an answer on June 6, 2026 at 7:00 am

    Are you getting your errors on this line?

    ViewGroup group= (ViewGroup)findViewById(R.id.popuplayout);
    
    ViewGroup group= (ViewGroup) layout.findViewById(R.id.popuplayout);//layout is your inflated
    

    I think it might be beacuse you need to use the value you called on the layout inflator.

    Anyway, I guess you should do instead: Get a reference of all your edit texts and then clear them one by one. Maybe keep an array of edit texts and walk through them and set their texts to “” instead of checking for the type.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am new to Android development. I have created a main Activity (->A), which
I'm new to Android development, I have created an animation which I have associated
I am new to Android development. I have created an Activity with the ListView
I am very new to android development.... i have created an app and want
I want to start android tablet application development. i have created a new avd
I am new to android development, I have created a string variable with EditText
I`m relatively new at Android development, although I have created a few basic applications.
I'm new to android apps development and I have a basic sqlite question. What
I am new in Android application development, but I have programming knowledge in iOS.
I have been learning android development and I am still new to this. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.