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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T22:48:27+00:00 2026-06-18T22:48:27+00:00

I have 1 viewflipper and it contains 3 layouts . Layout 1 has 2

  • 0

I have 1 viewflipper and it contains 3 layouts . Layout 1 has 2 button one to shownext and the other to go to another activity. the 2nd layout has 3 buttons. what I want is to know how to control the 2nd layout and make on click listenter on each button so I can make one for show next and the other to go to another activity.

this is the xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".MainActivity" >

    <ViewFlipper
        android:id="@+id/viewFlipper1"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true" >

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent" >

            <ImageView
                android:id="@+id/imageView1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentTop="true"
                android:layout_centerHorizontal="true"
                android:layout_marginTop="44dp"
                android:src="@drawable/ballchr3" />


            <ImageView
                android:id="@+id/imageView2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignTop="@+id/imageView1"
                android:layout_toLeftOf="@+id/imageView3"
                android:src="@drawable/ballchr4" />



        </RelativeLayout>


 <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent" >

            <ImageView
                android:id="@+id/imageView1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentTop="true"
                android:layout_marginTop="73dp"
                android:layout_toRightOf="@+id/imageView3"
                android:src="@drawable/ballchr3" />

            <ImageView
                android:id="@+id/imageView2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignTop="@+id/imageView1"
                android:layout_toLeftOf="@+id/imageView3"
                android:src="@drawable/ballchr4" />

            <ImageView
                android:id="@+id/imageView3"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentBottom="true"
                android:layout_centerHorizontal="true"
                android:layout_marginBottom="128dp"
                android:src="@drawable/ballchr5" />

        </RelativeLayout>


    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent" >

        <ImageView
            android:id="@+id/imageView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentTop="true"
            android:layout_alignRight="@+id/imageView2"
            android:layout_marginTop="76dp"
            android:src="@drawable/ballchr3" />

    </RelativeLayout>        



    </ViewFlipper>

</RelativeLayout>

Activity Code

public class MainActivity extends Activity implements OnClickListener {

    ViewFlipper viewflipper;
    ImageView btn, fail;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        viewflipper = (ViewFlipper)findViewById(R.id.viewFlipper1);
        btn = (ImageView)findViewById(R.id.imageView1);
        fail = (ImageView)findViewById(R.id.imageView2);

        btn.setOnClickListener(this);
        fail.setOnClickListener(this);

    }


    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }


    @Override
    public void onClick(View arg0) {
        // TODO Auto-generated method stub

        switch(arg0.getId()){
        case R.id.imageView1:
            viewflipper.showNext();
            break;

        case R.id.imageView2:
            Intent i = new Intent(MainActivity.this, Fail.class);
            startActivity(i);
            break;
        }
    }
  • 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-18T22:48:28+00:00Added an answer on June 18, 2026 at 10:48 pm

    First of all, do not repeat the id’s in the same xml file, i can see that u used imageView1, 2 and 3 multiple times. Do not do that.

    To answer your question, Declare more imageViews in your activity and assign them to your respective buttons as you have already done above and set their onClickListeners,implement them. since its in the same xml, when the view exits its references will also exist.

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

Sidebar

Related Questions

I have three layouts with viewflipper. I want one layout to be able to
I have two views in my ViewFlipper . One of views contains a ListView
I have a viewflipper that I want to populate with the same layout multiple
I have a ViewFlipper which contains a few linear layouts. I need to allow
I have a two layout in a ViewFlipper which contains ScrollView in each of
My situation is following. I have one Activity that contains three main parts. At
In my application I have an activity which contains a viewflipper with 3 listviews
I have a ViewFlipper in which I want to add Views (Relative Layout with
My viewFlipper contains 15 LinearLayout. After it reaches, I have a button Back to
I have a LinearLayout , containg a ScrollView of ViewFlipper layouts. I've only included

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.