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

  • Home
  • SEARCH
  • 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 7596439
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T21:55:05+00:00 2026-05-30T21:55:05+00:00

It is possible using Dialog class but I do not want it that way.

  • 0

It is possible using Dialog class but I do not want it that way. Instead I want it to be done by using PopupWindow class which gets popped up on startup and display some message on the popup. I am helpless, just can not getting this after spending many days behind it. Hope I get it here. Please and Thanks. Also look at below snippet if you didn’t get what I want..

public class PopupActivity extends Activity implements OnClickListener {

    LinearLayout ll = new LinearLayout(this);
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(ll);
    }

    protected void onStart() {
        super.onStart();
        final PopupWindow pw;
        Button button = new Button(this);
        button.setText("Hello");
        pw = new PopupWindow(button, 245, 284, true);

        button.setOnClickListener(new OnClickListener() {  
            @Override  
            public void onClick(View view) {  
                pw.dismiss();            
            }  
        });

        pw.showAsDropDown(ll, 10, -50);
    }
}

Above code gives me FORCE CLOSE :/ Help guys..

  • 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-30T21:55:07+00:00Added an answer on May 30, 2026 at 9:55 pm

    this is how you may show a popup window.

    main.xml

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_height="fill_parent" 
        android:layout_width="fill_parent"
        android:orientation="vertical"
        android:id="@+id/layoutTemp">
    
    </LinearLayout>
    

    popup_layout.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"
        android:background="#FFFFFF">
    
        <TextView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="10dip"
            android:text="Test Pop-Up" />
    
    </LinearLayout>
    

    main.java

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    
        new Handler().postDelayed(new Runnable() {
            public void run() {
                showPopup();
            }
        }, 100);
    }
    
    
    public void showPopup(){
        LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    
        PopupWindow pw = new PopupWindow(inflater.inflate(R.layout.popup_layout, null, false), 100, 100, true);
        pw.showAtLocation(findViewById(R.id.layoutTemp), Gravity.CENTER, 0, 0);
    }
    

    The idea is that your popup will be displayed once your activity is loaded, otherwise it will produce exception Unable to add window — token null is not valid; is your activity running?. Unless you show popup on a button click, that is the reason I’m showing it after a delay of 100 milliseconds (which is almost unnoticeable).

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

Sidebar

Related Questions

Is it possible using jQuery to select all <a> links which href ends with
I know this is probably possible using Streams, but I wasn't sure the correct
I'm looking after a way to AlphaBlend a child form, if possible using layered
Is it possible that using jQuery, I cancel/abort an Ajax request that I have
I'm using this dialog: http://docs.jquery.com/UI/Dialog To open dialog I do it this way: $('a.openModal').live(click,
I am trying to create a custom dialog class that inherits from Dialog that
I am working on a simple class browser dialog that allows users to open
I want to create a 'save as' file dialog with a filter, but this
Is this possible at all? When I create a form using MonoTouch.Dialog, it comes
In my android i am using progress dialog for showing loading screen but is

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.