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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T03:47:48+00:00 2026-05-18T03:47:48+00:00

I have popup in my android app. In popup I have button for closing

  • 0

I have popup in my android app. In popup I have button for closing popup with id=”imbClosePopUp”, but when I try to set to that button clickListener app crashs.

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

    <LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:gravity="right"
    android:layout_gravity="right"
    >
    <ImageButton
    android:id="@+id/imbClosePopUp"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="right"
    android:src="@drawable/close"
    ></ImageButton>
    </LinearLayout>
    <TextView
        android:text="CEKIRAJ OBAVEZNE KRITERIJUME"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content">
    </TextView> 
    <TableLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
    >
        <TableRow>
            <CheckBox
                android:id="@+id/chkw"
                android:checked="true"
                android:text="cg"
            ></CheckBox>
            <CheckBox
                android:id="@+id/chkq"
                android:checked="true"
                android:text="tv"
            ></CheckBox>
        </TableRow>
    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:gravity="right"
        android:layout_gravity="right"
>
        <Button
            android:id="@+id/btnSaveCrit"
            android:text="ok"
            android:layout_width="130dp"
            android:layout_height="wrap_content"
        >
        </Button>
    </LinearLayout>
</LinearLayout>

I set onclicklistener for button imbClosePopUp in function where I create Popup ( I create Popup on click some button ).

  private OnClickListener AdditionalC = new OnClickListener() {
        public void onClick(View v) {
            LayoutInflater inflater = (LayoutInflater)
            roomate.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
          pw = new PopupWindow(
            inflater.inflate(R.layout.popup, null, false), 
            300, 
            300, 
            true);
         // The code below assumes that the root container has an id called 'main'
         pw.showAtLocation(roomate.findViewById(R.id.tbC), Gravity.CENTER, 0, 0); 

         ImageButton imbClosePopUp=(ImageButton)findViewById(R.id.imbClosePopUp);
         imbClosePopUp.setOnClickListener(ClosePopUp);


        }
    };

Does anybody know what is the ptoblem and how to colse popup ?

  • 1 1 Answer
  • 1 View
  • 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-18T03:47:49+00:00Added an answer on May 18, 2026 at 3:47 am

    Assuming I understand the question alright, I suspect the problem is here:

    ImageButton imbClosePopUp=(ImageButton)findViewById(R.id.imbClosePopUp);
    

    That’s Activity.findViewById() you’re calling there, right? But you presumably want to be searching the popup‘s layout, not the activity’s. Try this:

    public void onClick(View v) {
        LayoutInflater inflater = (LayoutInflater)
        roomate.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View popupView=inflater.inflate(R.layout.popup, null, false);
        pw = new PopupWindow(popupView, 300, 300, true);
        pw.showAtLocation(roomate.findViewById(R.id.tbC), Gravity.CENTER, 0, 0); 
    
        ImageButton imbClosePopUp=(ImageButton)popupView.findViewById(R.id.imbClosePopUp);
        imbClosePopUp.setOnClickListener(ClosePopUp);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a popup window (selectReasonCode) that is opened up from a button. The
I am working on an Android App that implements Flash Peer-assisted networking. I have
I am new to android development. I have created a popup window which is
i have popup-window in my script. I use window.open, but almost all browsers block
I have a popup that stores a DataTable into a session so that after
I have a popup search box that is shown when the user mouses over
I have a popup menu that has a few items in it. Option 1
I have a popup function in a program that works well, be re-loads the
I am developing an Android app that connects to the Facebook Open Graph via
I have multiple popups in my android app. I would like to control the

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.