Question

HI im à l'aide de la fenêtrePageIndicator et avez configuré un espace de visualisation et des fragments qui fonctionne comme un charme! Le problème est que je ne semble pas obtenir le titre de TitlePageIndicator.C'est juste vide et ne montre rien.

<android.support.v4.view.ViewPager
        android:id="@+id/pager"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_above="@+id/indicator"
        android:layout_alignParentLeft="true"
        android:layout_below="@+id/textView2" >

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

   <com.viewpagerindicator.TitlePageIndicator
        android:id="@+id/indicator"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        android:padding="10dip"
        android:visibility="visible"
        app:linePosition="top" 
        android:theme="@style/CustomUnderlinePageIndicator"/> 

suspect que quelque chose ne va pas avec les styles.J'utilise le fichier de style de l'échantillon ViewPageIndicator.

Quand j'exicite ce code, je reçois une erreur de LogCat:

mPager = (ViewPager)findViewById(R.id.pager);

    mPager.setAdapter(mAdapter);

    mIndicator = (TabPageIndicator)findViewById(R.id.indicator);
    mIndicator.setViewPager(mPager);

Erreur: java.lang.classcastException: com.viewpagerindicator.titlepageindicator ne peut pas être jeté sur com.viewpagerindicator.TabpageIndicator

Était-ce utile?

La solution

dans votre modification XML TitlePageIndicator pour TabpageIndicator ou dans votre fichier change Mindicator= (TabpageIndicator) Findview (R.ID.Indicator); pour Mindicator= (TitlePageIndicator) Findveviede (R.ID.Indicator); pourquoi est-ce différent

Autres conseils

Utilisez ce code

MPAGER= (ViewPager) FOYVISHYID (R.ID.View_Pager); mpager.settadapter (Madapter);

    mIndicator = (TitlePageIndicator) findViewById(R.id.title_indicator);
    mIndicator.setViewPager(mPager);

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top