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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T20:51:06+00:00 2026-05-26T20:51:06+00:00

I have a layout displayed on a button click.I want to hide that layout

  • 0

I have a layout displayed on a button click.I want to hide that layout after 10 seconds.

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

    mVolHandler = new Handler();
    mVolRunnable = new Runnable() {
        public void run() {
            mVolLayout.setVisibility(View.GONE);
        }
    };
}


private OnTouchListener mVolPlusOnTouchListener = new OnTouchListener() {
    @Override
    public boolean onTouch(View v, MotionEvent event) {
        mVolLayout.setVisibility(View.VISIBLE);
        mVolHandler.postDelayed(mVolRunnable, 10000);
    }
}
  • 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-26T20:51:07+00:00Added an answer on May 26, 2026 at 8:51 pm

    Make use of Handler & Runnable.

    You can delay a Runnable using postDelayed of Handler.

    Runnable mRunnable;
    Handler mHandler=new Handler();
    
    mRunnable=new Runnable() {
    
                @Override
                public void run() {
                    // TODO Auto-generated method stub
                    yourLayoutObject.setVisibility(View.INVISIBLE); //If you want just hide the View. But it will retain space occupied by the View.
                    yourLayoutObject.setVisibility(View.GONE); //This will remove the View. and free s the space occupied by the View    
                }
            };
    

    Now inside onButtonClick event you have to tell Handler to run a runnable after X milli seconds:

    mHandler.postDelayed(mRunnable,10*1000);
    

    If you want to cancel this then you have to use mHandler.removeCallbacks(mRunnable);

    Update (According to edited question)
    You just need to remove callbacks from Handler using removeCallbacks()

    So just update your code inside onTouch method like this :

    mVolLayout.setVisibility(View.VISIBLE);
    mVolHandler.removeCallbacks(mVolRunnable);
    mVolHandler.postDelayed(mVolRunnable, 10000);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have code like this public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); boolean autoLogin
I have a partial that I want to display in a layout only when
I have 2 different layout files that I want to use for modifying the
I want to display a button that when I click adds to the main
I have a layout that is working, but it has one very annoying problem..
I have a layout in which I am displaying a webview . I want
I have this layout that works correctly, a relative layout with a text view
I have a main layout in which I'd like to sequentially display / hide
I have 3 buttons on each layout. When i clicked on button MOH in
I want a layout such that user can toggle between listview and mapview and

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.