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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T09:35:48+00:00 2026-06-16T09:35:48+00:00

I have a LinearLayout, I am dynamically adding TextView, ImageView to that LinearLayout ,

  • 0

I have a LinearLayout, I am dynamically adding TextView, ImageView to that LinearLayout, now I have added OnClickListener to these TextViews and ImageViews.

I have an arraylist which has 10 items in it, using a for loop I am getting each value and displaying, since it’s quiz app I have next and previous buttons, when I click on that I am displaying items one by one from the arraylist.Now I need slide In and slide Out animation to apply to this Linear Layout.

I have seen this :

Link 1

Link 2

and also I have tried this

slideIn = new TranslateAnimation(
    TranslateAnimation.RELATIVE_TO_PARENT, 1.0f,
    TranslateAnimation.RELATIVE_TO_PARENT, 0.0f,
    TranslateAnimation.RELATIVE_TO_PARENT, 0.0f,
    TranslateAnimation.RELATIVE_TO_PARENT, 0.0f);

slideIn.setDuration(500);
slideOut = new TranslateAnimation(
    TranslateAnimation.RELATIVE_TO_PARENT, 0.0f,
    TranslateAnimation.RELATIVE_TO_PARENT, -1.0f,
    TranslateAnimation.RELATIVE_TO_PARENT, 0.0f,
    TranslateAnimation.RELATIVE_TO_PARENT, 0.0f);

slideOut.setDuration(500);

But not working please help on this.

EDIT:

Problem: I have applied this to the linear layout but what happens is that when i click on next button current question will slide left and a blank screen then it will slide in and display next question, but I want as soon as the current question slides out it should be followed by next question.

  • 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-16T09:35:49+00:00Added an answer on June 16, 2026 at 9:35 am

    If your layouts are having identical content, create two layouts inside a view flipper.
    Load first view with data and show it.
    When user clicks next or previous, load next view with data and keep a flag to show that 2nd view is now visible and show it with animation.

    Now onwards load the appropriate views with data based on the flag values and call shownext().

    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    
        mainFlipper = (ViewFlipper) findViewById(R.id.flipper);
        firstLayout = (LinearLayout) findViewById(R.id.layout1);
        secondLayout = (LinearLayout) findViewById(R.id.layout2);
    
    
        findViewById(R.id.btnPrevious).setOnClickListener(new OnClickListener() {
    
            @Override
            public void onClick(View arg0) {
                showPrevious();
            }
        });
    
        findViewById(R.id.btnNext).setOnClickListener(new OnClickListener() {
    
            @Override
            public void onClick(View arg0) {
                showNext();
            }
        });
    
    }
    
    private void showNext() {
        mainFlipper.setInAnimation(AnimationUtils.loadAnimation(this, R.anim.slide_in_left));
        mainFlipper.setOutAnimation(AnimationUtils.loadAnimation(this, R.anim.slide_out_right));
        flip();
    }
    
    private void showPrevious() {
        mainFlipper.setInAnimation(AnimationUtils.loadAnimation(this, R.anim.slide_in_right));
        mainFlipper.setOutAnimation(AnimationUtils.loadAnimation(this, R.anim.slide_out_left));
        flip();
    }
    
    private void flip() {
        if(isFirstVisible) {
            isFirstVisible = false;
            secondLayout.removeAllViews();
            secondLayout.addView(getTextView("Second"));
        } else {
            isFirstVisible = true;
            firstLayout.removeAllViews();
            firstLayout.addView(getTextView("First"));
        }
        mainFlipper.showNext();
    }
    
    private TextView getTextView(String txt) {
        TextView txtView = new TextView(this);
        txtView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
        txtView.setText(txt);
        return txtView;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a LinearLayout in which I am adding some CheckBoxes dynamically, they are
I have a horizontalscrollview containing many textviews that are added dynamically. When I press
H have multiple TextViews inside an LinearLayout . Now I want to delete this
I have an Activity that has all the display elements added dynamically. Theres no
Hi I am using listview which have multiple items adding dynamically.. I want to
I have a listview where I have to added data dynamically to linearLayout ,
I have Radio buttons that are created dynamically. LinearLayout linLayRoot = (LinearLayout)dialogView.findViewById(R.id.dialog_layout_root); RadioGroup radGp
I have these text fields which I generated dynamically. But I can't seem to
I have a LinearLayout which holds a couple of buttons. To give the user
I have a LinearLayout and its child - ImageView. My activity's onCreate does nothing

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.