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 4613568
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T01:34:15+00:00 2026-05-22T01:34:15+00:00

To create a simple working PopupWindow, we need to do the following: popup_example.xml: <?xml

  • 0

To create a simple working PopupWindow, we need to do the following:

popup_example.xml:

<?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical"
        android:padding="10dip"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content">

        <TextView         
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="10dip"
            android:text="Test Pop-Up" />

    </LinearLayout>

Java code

LayoutInflater inflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE); 

PopupWindow pw = new PopupWindow(inflater.inflate(R.layout.popup_example, null, false),100,100, true);

pw.showAtLocation(this.findViewById(R.id.main), Gravity.CENTER, 0, 0);

My requirement is that I need a

<TEXTVIEW android:layout_height="wrap_content" android:layout_width="fill_parent" />

and a

<BUTTON android:id="@+id/end_data_send_button" android:text="Cancel"/>

in my popup_example.xml. How can I handle these two components in my Java code?

screenshot

  • 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-05-22T01:34:15+00:00Added an answer on May 22, 2026 at 1:34 am

    Here, I am giving you a demo example. See this and customize it according to your need.

    public class ShowPopUp extends Activity {
        PopupWindow popUp;
        boolean click = true;
    
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            popUp = new PopupWindow(this);
            LinearLayout layout = new LinearLayout(this);
            LinearLayout mainLayout = new LinearLayout(this);
            TextView tv = new TextView(this);
            Button but = new Button(this);
            but.setText("Click Me");
            but.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View v) {
                    if (click) {
                         popUp.showAtLocation(layout, Gravity.BOTTOM, 10, 10);
                         popUp.update(50, 50, 300, 80);
                         click = false;
                    } else {
                         popUp.dismiss();
                         click = true;
                    }
                }
            });
    
            LayoutParams params = new LayoutParams(LayoutParams.WRAP_CONTENT,
                LayoutParams.WRAP_CONTENT);
            layout.setOrientation(LinearLayout.VERTICAL);
            tv.setText("Hi this is a sample text for popup window");
            layout.addView(tv, params);
            popUp.setContentView(layout);
            // popUp.showAtLocation(layout, Gravity.BOTTOM, 10, 10);
            mainLayout.addView(but, params);
            setContentView(mainLayout);
       }
    }
    

    Hope this will solve your issue.

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

Sidebar

Related Questions

I'm working on a simple crawler in Python. The aim is to create a
I need to create simple reusable javascript object publishing several methods and parameterized constructor.
How to create simple PHP COMET server page displaying current time? I need code
I'm working to create a simple Python script that will ultimately tell you how
So I'm trying to create a simple file transfer method. It's completely working for
How to create Simple HLSL Silverlight filter for blending/playing with/mixing 2 images? I need
I need to create a simple fixed width text file in KornShell (ksh). My
I'm trying to create a simple Android UI that consists of a EditText and
I am working with DataMapper and Sinatra to create a simple app. Here's the
I am currently working on a project to create simple file uploader site that

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.