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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T13:00:41+00:00 2026-06-15T13:00:41+00:00

There is an image shown below for what I am looking for. Currently I

  • 0

There is an image shown below for what I am looking for. Currently I am using view pager & circle indicator. In view page it is showing only a single image.

I want in one viewpager three images as shown in pic. When I slide that page, again three different images loaded form server with text below. How to do this? Any idea regarding this or any other way to achieve this?

My code is shown below.

I add some xml layout here: homespizzaview.xml

  <LinearLayout
        android:id="@+id/linearLayoutbutton"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="10dip" >

   <android.support.v4.view.ViewPager
    android:id="@+id/pagerMenu"
    android:layout_width="0dip"
    android:layout_height="100dip"
    android:layout_weight="1"
    android:layout_marginLeft="10dip"
    android:layout_marginRight="10dip">

          </android.support.v4.view.ViewPager>   
    </LinearLayout>


  <RelativeLayout
    android:id="@+id/relativeLayoutDot1"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_marginTop="5dip">
  <com.viewpagerindicator.CirclePageIndicator
   android:id="@+id/indicatorMenu"
   android:layout_width="fill_parent"
   android:layout_height="25dip"
   android:layout_marginLeft="10dip"
   android:layout_marginRight="10dip"
   android:padding="10dip" />

 </RelativeLayout>

HomeView .java

 public class HomeView extends Activity {

    adaptermenu = new MenuPagerAdapter();
    pagerMenu = (ViewPager)findViewById(R.id.pagerMenu);
    pagerMenu.setAdapter(adaptermenu);
    pagerMenu.setCurrentItem(0);
    pagerMenu.setOffscreenPageLimit(adapter.getCount());
    pagerMenu.getAdapter().notifyDataSetChanged();
    pagerMenu.setPageMargin(15);

    indicator  = (CirclePageIndicator)findViewById(R.id.indicatorMenu);
    indicator.setViewPager(pagerMenu);

    final float density1 = getResources().getDisplayMetrics().density;
    indicator.setRadius(5 * density1);
    indicator.setPageColor(0xFF000000);
    indicator.setFillColor(0xFF888888);
    indicator.setStrokeWidth(2 * density1);

    //We set this on the indicator, NOT the pager
    indicator.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {             
        @Override
        public void onPageSelected(int position) {
         //   Toast.makeText(HomeSpizzaView.this, "Changed to page " + position, Toast.LENGTH_SHORT).show();
            pagerMenu.setCurrentItem(position, false);            
        }
        @Override
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
        }
        @Override
        public void onPageScrollStateChanged(int state) {               
        }
    });

    indicator.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {

            pagerMenu.setCurrentItem(0);  
          Log.i("", "getCurrentItem"+  mPager.getCurrentItem());
          pagerMenu.getAdapter().notifyDataSetChanged();
        }
    });

       }
    } 

MenuPagerAdapter.java

 public class MenuPagerAdapter extends PagerAdapter {


public int getCount() {
    return 3;
}

public Object instantiateItem(View collection, int position) {

    ImageView image = new ImageView(collection.getContext()); 
    image.setPadding(20, 0, 20, 0);     
    int resId = 0;
    switch (position) {
    case 0:
        resId = R.drawable.promotion1;
        break;
    case 1:
        resId = R.drawable.promotion2;
        break;
    case 2:
        resId = R.drawable.promotion3;
        break;
    }
    image.setImageResource(resId); 
    ((ViewPager) collection).addView(image, 0);

    return image;
}

@Override
public void destroyItem(View arg0, int arg1, Object arg2) {
    ((ViewPager) arg0).removeView((View) arg2);

}

@Override
public boolean isViewFromObject(View arg0, Object arg1) {
    return arg0 == ((View) arg1);

}

@Override
public Parcelable saveState() {
    return null;
}
}

here is update code which is showing single image view with below textview. i am looking for dynamic image & text.. means In 1 view pager 3 images with 3 text.. currently its showing 1 image view with below text.. I am looking for 3 images in single viewpager.. if i add linear layout it shows 3 image. but i add relative layout its showing single images.. ANY IDEA WHAT I MADE MISTIKE.

 public Object instantiateItem(View collection, int position) {

    RelativeLayout  lLayout;      
    RelativeLayout.LayoutParams relativeLayout;

    lLayout = new RelativeLayout (collection.getContext());
      relativeLayout = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.FILL_PARENT);

        for (int i = 0; i < 3; i++) {
            image = new ImageView(collection.getContext());
            image.setPadding(20, 0, 20, 0); 
            image.setId(1);
            int res = 0;
          switch (0) {
          case 0:
              res = R.drawable.menu_antipasti;          
              break;
          case 1:
              res = R.drawable.menu_combos;
              break;
          case 2:
              res = R.drawable.menu_drinks;
              break;
          }                  
            image.setImageResource(res);
            lLayout.addView(image);

            textview = new TextView(collection.getContext());
            textview.setTextColor(Color.BLACK);
            textview.setId(2);
            textview.setText("pizza");  
            textview.setPadding(60, 0, 20, 0);
            relativeLayout.addRule(RelativeLayout.BELOW, image.getId());
            lLayout.addView(textview, relativeLayout);
        }

        ((ViewPager) collection).addView(lLayout, 0);
        return lLayout;
    }
  • 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-15T13:00:43+00:00Added an answer on June 15, 2026 at 1:00 pm

    Now you’re returning ImageView from instantiateItem method. If you want to have 3 images on 1 page you need to create layout, place 3 images on it and return it. E.g:

    public Object instantiateItem(View collection, int position) {
        LinearLayour images = new LinearLayout(collection.getContext());
        for (int i = 0; i < 3; i++) {
            ImageView image = new ImageView(collection.getContext());
            image.setPadding(20, 0, 20, 0);     
            images.addView(image);
            int res = someResource depending on i and position.
            image.setImageResource(res);
        }
    
        ((ViewPager) collection).addView(images, 0);
        return images;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am looking for an image display script similar to the samples shown below.
I have three tables as shown in below image. Note: Lead column of projectheader
Image the following situation: You're on Windows XP (even though the dialog shown below
Im looking for a way to change the background image of a div using
I defined two CSS classes that set the background to an image (shown below).
There are a lot of posts to show to create a virtual floppy image
I want to show an image view for three like on/off,if any one have
In an image there is a face, which is tilted a bit and has
Is there an image processing algorithm that can fill these gaps within an image?
I have an audio track with an image slideshow - e.g. there's image 1

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.