0

i used https://github.com/JakeWharton/Android-ViewPagerIndicator ,the lib is very cool,but when i used i meet a question: at the simple_circles.xml :

<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">

<android.support.v4.view.ViewPager
    android:id="@+id/pager"
    android:layout_width="fill_parent"
    android:layout_height="0dp"
    android:layout_weight="1"
    />
<com.viewpagerindicator.CirclePageIndicator
    android:id="@+id/indicator"
    android:padding="10dip"
    android:layout_height="wrap_content"
    android:layout_width="fill_parent"
    />
</LinearLayout>

i modify the code :

 <LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">

 <com.viewpagerindicator.CirclePageIndicator
    android:id="@+id/indicator"
    android:padding="10dip"
    android:layout_height="wrap_content"
    android:layout_width="fill_parent"
    />
<android.support.v4.view.ViewPager
    android:id="@+id/pager"
    android:layout_width="fill_parent"
    android:layout_height="0dp"
    android:layout_weight="1"
    />

</LinearLayout>

it give me CirclePageIndicator cannot be cast to android.support.v4.view.ViewPager

edit:who give me -1, can you give some reason.i want to name-calling

pengwang
  • 19,536
  • 34
  • 119
  • 168

1 Answers1

1
  <LinearLayout
           xmlns:android="http://schemas.android.com/apk/res/android"
           android:orientation="vertical"
           android:layout_width="fill_parent"
           android:layout_height="fill_parent">

           <com.viewpagerindicator.CirclePageIndicator
              android:id="@+id/indicator"
              android:padding="10dip"
               android:layout_height="wrap_content"
              android:layout_width="fill_parent"
            />
       <android.support.v4.view.ViewPager
          xmlns:android="http://schemas.android.com/apk/res/android"
          android:id="@+id/pager"
           android:layout_width="fill_parent"
          android:layout_height="0dp"
          android:layout_weight="1"
      />

  </LinearLayout>

add xmlns:android="http://schemas.android.com/apk/res/android" to the ViewPager,all is ok,but i donot know why

pengwang
  • 19,536
  • 34
  • 119
  • 168
  • ur trick is working...+1 from me...but i m using LinePageIndicator instead of CirclePageIndicator...also i have to change my xml to above that u have mentioned...! – TheFlash Aug 24 '13 at 04:45
  • yes i can run it above the pager...that's y i have given u +1..this trick is working.@pengwang – TheFlash Aug 24 '13 at 04:50
  • check 2nd answer..http://stackoverflow.com/questions/1181888/what-does-xmlns-in-xml-mean @pengwang – TheFlash Aug 24 '13 at 04:55