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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T19:33:53+00:00 2026-06-11T19:33:53+00:00

I have a problem actually with my app, my ViewPager and ViewPagerIndicator ( http://viewpagerindicator.com/

  • 0

I have a problem actually with my app, my ViewPager and ViewPagerIndicator
( http://viewpagerindicator.com/) are not displaying anything and i don’t see why. I checked everything multiple times (setting correctly the adapter, adding the view in instantiateItem, returning the good size in getCount(),…), tried a few things (changing the layout params in the xml, reworking the MyPagerAdapter class), even looking for a similar issue in Google and here but nothing worked/wans’t my problem.

I also have a bog, don’t know if that has a link, but the instantiateItem method in my PagerAdapter is only called 2 times, while getCount() is well returning 3.

I really don’t know where that can come from, if anybody has an idea i’ll take it with great pleasure :

OnCreate (Of the Activity containing the ViewPager & ViewPagerIndicator) :

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_infos_vehicle);

    title = (TextView) findViewById(R.id.title);

    ll = (LinearLayout) findViewById(R.id.mygallery);

    filenames = new ArrayList<String>();

    [...]

    MyPagerAdapter adapter = new MyPagerAdapter(getResources().getStringArray(R.array.infos_vehicle));

    ViewPager pager = (ViewPager) findViewById(R.id.pager);
    pager.setAdapter(adapter);

    TitlePageIndicator indicator = (TitlePageIndicator) findViewById(R.id.titles_pager);
    indicator.setFooterIndicatorStyle(IndicatorStyle.Triangle);
    indicator.setViewPager(pager);

    [...]
}

MyPagerAdapter class (The 3rd case was here for a more visible test, see if it wasn’t my fillGeneral or fillEquipments methods that were messed up) :

private class MyPagerAdapter extends PagerAdapter {

private final String[] TITLES;

public MyPagerAdapter(String[] titles) {
    TITLES = titles;
}

    @Override
    public int getCount() {
        return (TITLES.length);
    }

    @Override
    public Object instantiateItem(View collection, int position) {
        LayoutInflater inflater = (LayoutInflater) getApplicationContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View v = null;

        switch (position) {
        case (0):
            v = inflater.inflate(R.layout.linear_layout, null);
            fillGeneral((ViewGroup) v.findViewById(R.id.layout));
            break;
        case (1):
            v = inflater.inflate(R.layout.linear_layout, null);
            fillEquipments((ViewGroup) v.findViewById(R.id.layout));
            break;
        case (2):
            v = new ImageView(getApplicationContext());
            ((ImageView) v).setImageDrawable(getApplicationContext().getResources().getDrawable(android.R.drawable.alert_dark_frame));
            break;
        }
        ((ViewPager) collection).addView(v);
        return (v);
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return (TITLES[position]);  
    }

    @Override
    public void destroyItem(View collection, int position, Object view) {
        ((ViewPager) collection).removeView((View) view);
    }

    @Override
    public boolean isViewFromObject(View arg0, Object arg1) {
        return (arg0.equals(arg1));
    }

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

}

And the activity xml :

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" >

        <TextView
            android:id="@+id/title"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentTop="true"
            android:layout_centerHorizontal="true"
            android:layout_marginTop="10dp"
            android:text="@string/hello_world"
            android:textAppearance="?android:attr/textAppearanceLarge"
            android:textColor="@color/first_color" />

        <Button
            android:id="@+id/try_vehicle"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/title"
            android:layout_centerHorizontal="true"
            android:layout_marginTop="40dp"
            android:onClick="tryingAlert"
            android:text="@string/try_vehicle" />

        <Button
            android:id="@+id/ask_informations"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/try_vehicle"
            android:layout_centerHorizontal="true"
            android:layout_marginTop="20dp"
            android:onClick="informationsAlert"
            android:text="@string/ask_informations" />

        <Button
            android:id="@+id/remove_selection"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:onClick="removeFromSelection"
            android:layout_below="@+id/ask_informations"
            android:layout_centerHorizontal="true"
            android:layout_marginTop="20dp"
            android:text="@string/remove_selection" />

        <HorizontalScrollView
            android:id="@+id/scroll"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_below="@+id/remove_selection"
            android:layout_marginTop="18dp"
            android:scrollbars="none" >

            <LinearLayout
                android:id="@+id/mygallery"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:orientation="horizontal" >
            </LinearLayout>

        </HorizontalScrollView>

        <com.viewpagerindicator.TitlePageIndicator
            android:id="@+id/titles_pager"
            android:layout_below="@id/scroll"
            android:layout_height="wrap_content"
            android:layout_width="fill_parent" />

        <android.support.v4.view.ViewPager
            android:id="@+id/pager"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_below="@id/titles_pager" />

    </RelativeLayout>
</ScrollView>

What it gives me (The Activity ends here and as shown, the ViewPagerIndicator displays nothing) :
https://i.stack.imgur.com/xhyYI.jpg (External link, can’t post pictures sorry!)

  • 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-11T19:33:54+00:00Added an answer on June 11, 2026 at 7:33 pm

    Ok so there wasn’t any problem in the end, just me doing mistakes.

    As said, the ViewPagerIndicator was just white on white so i can’t see it, fine now.

    For the ViewPager, it was just at the very end of my ScrollView, meaning there was no “real” screen space available for it, so the android:layout_height="match_parent" was uneffective. That seems a common issue with ViewPager, i’ll see what i can do to adapt that.

    Thanks anyway for the help, i hope this post can be useful to someone !

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

Sidebar

Related Questions

I have problem with http://abfoodpolicy.com/ . In IE 8 and 9 the right sidebar
Actually, this is my problem. I have a rails app with a MainController, a
I need to script my app (not a game) and I have a problem,
I'm facing following problem actually: I'm using Spring with jQuery. I have Controller: @Controller
i have a problem with upload mutilply files using zend framework on server actually
I have a problem. Actually in our application, earlier the customer was allowed to
I have a problem with my code. Actually it works, but I want to
I have a problem with my Binding to a ListBox Control. Actually i have
i have a problem to order a list by certain rule. Actually i have
I make the problem shorter. Actually I have data much longer than this. I

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.