문제

안녕하세요 IM ViewPageIndicator를 사용하고 매력처럼 작동하는 뷰 파이버와 조각을 설치하십시오! 문제는 내가 TitlePageIndicator를 작동시키는 것처럼 보이지 않는 것입니다.그것은 단지 비어 있고 dosnt는 아무것도 보여줍니다.

<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"/> 
.

스타일에 무언가가 잘못되었다고 의심하십시오.viewPageIndicator 샘플에서 스타일 파일을 사용합니다.

이 코드를 exicute 할 때 다음 logcat 오류가 발생합니다.

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

    mPager.setAdapter(mAdapter);

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

오류 : java.lang.ClassCastException : com.viewPagerIndicator.TitlePageIndicator를 com.viewPagerIndicator.TabPageIndicator에 캐스팅 할 수 없습니다

도움이 되었습니까?

해결책

xml titlePageIndicator tabPageIndicator 또는 파일 변경시 mindicator= (tabpageIndicator) findViewById (r.id.indicator); ...에 대한 mindicator= (titlePageIndicator) findViewById (r.id.indicator); 가 다른 이유는 무엇입니까?

다른 팁

이 코드를 사용

mpager= (viewpager) findViewById (r.id.view_pager); mpager.setAdapter (Madapter);

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top