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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T06:45:07+00:00 2026-05-23T06:45:07+00:00

I have a strange problem I don’t understand… I want to do a PopupWindow

  • 0

I have a strange problem I don’t understand…

I want to do a PopupWindow from an XML file:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/popup" 
android:layout_width="match_parent" 
android:layout_height="match_parent"
android:background="#404040"
android:padding="15px">

<TextView android:id="@+id/popup_title"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:textColor="#ffffff" 
    android:textSize="16dip" 
    android:gravity="center_horizontal" />

</LinearLayout>

and I just want to do a so simple thing: set the text in my TextView… Here is my code:

public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);     

//UI
ui = new RelativeLayout(this);
ui.setBackgroundColor(Color.LTGRAY);
setContentView(ui);

//PopUp
LayoutInflater inflater = (LayoutInflater)this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
popUp = new PopupWindow(this);
popUp.setContentView(inflater.inflate(R.layout.popup_piece, ui, false));


    //Boutton
    bouton = new Button(this);
    bouton.setText("POWPEUP");
    ui.addView(bouton);

    bouton.setOnClickListener(new OnClickListener() {

        public void onClick(View v) {

            popUp.showAtLocation(ui, Gravity.CENTER, 0, 0);
            popUp.update(0, 0, 350, 400);

            titrePopUp = (TextView)findViewById(R.id.popup_title); // THIS RETURNS NULL
            Log.d("TextView", ""+titrePopUp);
                            //titrePopUp.setText("blop", TextView.BufferType.NORMAL); SO THIS DONT WORK
        }
    });
}

Seriously, I don’t understand why it returns a NULL value.. Can anyone help me, please?

  • 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-23T06:45:08+00:00Added an answer on May 23, 2026 at 6:45 am

    You are searching for the TextView in your main layout, not in the PopupWindow. You need to do this instead:

    titrePopUp = (TextView) popUp.getContentView().findViewById(R.id.popup_titre);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a strange problem that I don't understand about DataPager. After changing the
I have a strange problem with inheritance and I don't understand why it should
I have a strange problem with lxml when using the deployed version of my
I have a rather strange problem, well strange to me. I have a file
I have a super strange problem. I want a Textured window to have it
I have a very strange problem , please don’t ask me why do I
I have strange problem with sharepoint and ajax functionality. We have an UpdatePanel placed
i have strange problem doing reporting: i have numerous clients with different issued invoices.
We have very strange problem, one of our applications is continually querying server by
I have a strange problem with mod_rewrite, the rules that are relevant here are:

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.