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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T12:55:23+00:00 2026-06-13T12:55:23+00:00

I have a popup button that is working fine. When i click on it

  • 0

I have a popup button that is working fine. When i click on it it gets dismissed.
But i also want to add in a code for dismissing the popup after 5 secs if the user does not take any action on it? Is that possible?

The current code

final ImageButton rredButton=(ImageButton)findViewById(R.id.RredButton);
    rredButton.setOnClickListener(new View.OnClickListener() {

        public void onClick(View arg0) {
            LayoutInflater layoutInflater
            = (LayoutInflater)getBaseContext()      
            .getSystemService(LAYOUT_INFLATER_SERVICE);
            View popupView = layoutInflater.inflate(R.layout.popupright, null);
            final PopupWindow popupWindow = new PopupWindow(               
                    popupView,                
                    LayoutParams.WRAP_CONTENT,                       
                    LayoutParams.WRAP_CONTENT);     
            Button btnNxtScr = (Button)popupView.findViewById(R.id.nextscreen);             
            btnNxtScr.setOnClickListener(new Button.OnClickListener(){     
                @Override     
                public void onClick(View v) {      
                    Intent myintent1 = new Intent(colorActivity.this,colorBlueActivity.class);
                    startActivity(myintent1);
                }
            });
                    popupWindow.showAtLocation(rredButton, Gravity.CENTER, 0, 0);
                    //---                          
                    popupWindow.setFocusable(true);             
                    popupWindow.update();                          
                    //---
        }});

This is my updated code. What is wrong?

final ImageButton rredButton=(ImageButton)findViewById(R.id.RredButton);
    rredButton.setOnClickListener(new View.OnClickListener() {

        private CountDownTimer mPopUpDismissTimer; 
        public void onClick(View arg0) {
            LayoutInflater layoutInflater
            = (LayoutInflater)getBaseContext()      
            .getSystemService(LAYOUT_INFLATER_SERVICE);
            View popupView = layoutInflater.inflate(R.layout.popupright, null);
            final PopupWindow popupWindow = new PopupWindow(               
                    popupView,                
                    LayoutParams.WRAP_CONTENT,                       
                    LayoutParams.WRAP_CONTENT);     

            getPopUpDismissTimer(3000, 1000);
            mPopUpDismissTimer.start(); 

        }
            private void getPopUpDismissTimer(long millisInFuture, long countDownInterval) { 
            mPopUpDismissTimer = new CountDownTimer(millisInFuture, countDownInterval) {


            @Override
            public void onFinish() {
                Button btnNxtScr = (Button)popupView.findViewById(R.id.nextscreen);             
                btnNxtScr.setOnClickListener(new Button.OnClickListener(){     

                @Override     
                public void onClick(View v) {      
                    Intent myintent1 = new Intent(colorActivity.this,colorBlueActivity.class);
                    myintent1.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                    startActivity(myintent1);

                                };

        });
                popupWindow.showAtLocation(rredButton, Gravity.CENTER, 0, 0);
                //---                          
                popupWindow.setFocusable(true);             
                popupWindow.update();                          
                //---
            }

            @Override
            public void onTick(long millisUntilFinished) {

            }
            };
            }});
  • 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-13T12:55:24+00:00Added an answer on June 13, 2026 at 12:55 pm

    Get a CountDownTimer like this,

    private CountDownTimer mPopUpDismissTimer; // instance variable, put in your activity class

    private void getPopUpDismissTimer(long millisInFuture, long countDownInterval) {
    PopUpDismissTimer = new CountDownTimer(millisInFuture, countDownInterval) {

        @Override
        public void onFinish() {
          // put your logic for dismissing popup button
        }
    
        @Override
        public void onTick(long millisUntilFinished) {
    
        }
    };
    

    }

    Now, invoke this Count Down Timer where you want to dismiss popup, like –

    getPopUpDismissTimer(5000, 1000); //5000 ms is the time when you want to dismiss popup
    mPopUpDismissTimer.start();

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

Sidebar

Related Questions

when i click on Buttonfield i want to show Popup screen .everything working fine
I have a button that opens a panel in a popup window and then
I have a Java swing application with a button that produces a popup window
I have a popup window (selectReasonCode) that is opened up from a button. The
I have a HTML page on click of button i am displaying a Popup
I have an ajax modal popup, which is shown on click of a button
I have a button that activate a service but before that service is activate
I have a button that needs to open a new window as a popup
I have a button, when you click on that button, I'm doing a fadeToggle()
I have button that a user selects and I pop up a AlertDialog to

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.