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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T04:21:09+00:00 2026-05-23T04:21:09+00:00

I have a main layout in which I’d like to sequentially display / hide

  • 0

I have a main layout in which I’d like to sequentially display / hide various custom layouts according to timers and user input.

In my example, I’d like the following timeline:

  1. show an initial layout, created by the class MainStart. The user will click on the button when they’re ready to start.

  2. after the user clicks, we’ll run a countdown timer, displaying the countdown to the screen. This is done by MainCountdown.

  3. once the countdown is complete, MainLast is displayed. It has a button allowing the user to click “Again?” when they want to start over.

  4. if the user clicks “Again?” then go to step 1.

According to this question, I may have to use removeView() and addView() to achieve what I want.

I pushed to GitHub a trimmed down version of what I want to do: Hide and Show Layouts so you can see everything, but the problem seems to boil down to myView still being visible after this:

myView = inflate(mContext, R.layout.main_start, _view_group);
myView.setVisibility(View.GONE);

direct link to code on GitHub

direct link to related layout

Can I make a small change to my code/layouts to make the views hide/appear the way I want?

Am I completely Doing It Wrong?

  • 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-23T04:21:10+00:00Added an answer on May 23, 2026 at 4:21 am

    From your 1-4 steps, it sounds like a custom View might be overkill for this, but if for whatever reason, you require that it be a custom View, it can still be done pretty easily… And it can be done with a ViewFlipper (or other ViewAnimator), or you can simply have 3 sibling children, and set visibility of each as needed. A bird’s eye view would be something like…

    <ViewSwitcher
        android:layout_height="wrap_content"
        android:layout_width="match_parent">
    
        <Button
            android:id="@android:id/button1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Go" />
    
        <TextView
            android:id="@android:id/text1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
    
        <Button
            android:id="@android:id/button2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Again" />
    
    </ViewSwitcher>
    
    1. startCountdown(): setDisplayedChild(1) — this is the TextView. Also start the countdown: this can be with a Timer object, or using View#postDelayed().

    2. onCountdownComplete(): setDisplayedChild(2) — this shows the end “Again?” button.

    3. onClick of button2: setDisplayedChild(0)

    The countdown can be done with postDelayed() and a Runnable object to decrement the counter, or possibly more performant: use sendEmptyMessageDelayed(). When that handler message is received, decrement the internal counter, and update the TextView.

    Edit
    Another option for the countdown is CountDownTimer — similar concept, but has more of a “callback” feel to it. Your tick interval would be 1000, and millisInFuture would be 1000 * <numberOfSeconds>. In the onTick() method, update the TextView with millisUntilFinished / 1000. In the onFinish() method, call setDisplayedChild(2).

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

Sidebar

Related Questions

I have a main MasterPage which has a single column layout for the web
I have a reasonably complex layout problem: I would like to have a main
Suppose I have the following directory layout in a Maven project: src/ |-- main
i have a table called category in which i have main category ids and
I have a main asp.net app, which is written in asp.net 1.1. Runnning underneath
I have a main window (#1) on my webpage from which I open a
I am trying to build a layout dynamically which display some text and image
Hello I have a bunch of text on my file which i display. I
I have a main canvas 'blackboard' in a panel, this canvas has itself several
I have my main GUI thread, and a second thread running inside it's own

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.