Android CirclePageIndicator不工作
我无法加载带有circlepageindicator的页面。这是xmlAndroid CirclePageIndicator不工作,android,android-layout,android-support-library,Android,Android Layout,Android Support Library,我无法加载带有circlepageindicator的页面。这是xml <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <ImageView android:src="@drawa
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ImageView android:src="@drawable/bg2" android:layout_width="match_parent"
android:layout_height="match_parent" />
<LinearLayout android:layout_width="220dp"
android:orientation="vertical" android:layout_gravity="center_horizontal"
android:layout_height="32dp" android:layout_marginTop="32dp">
<android.support.v4.view.ViewPager
android:layout_width="match_parent" android:layout_height="match_parent"
android:id="@+id/myfivepanelpager" />
<com.viewpagerindicator.CirclePageIndicator
android:id="@+id/indicator"
android:padding="10dip"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
/>
</LinearLayout>
杰克·沃顿项目已被添加到图书馆。它在构建时不会给出任何错误,但不会加载页面。怎么了?您的ViewPager设置为与父视图匹配,这将阻止容器中的任何其他视图显示。使用android:layout\u weight=1将ViewPager高度设置为0dp
该容器还硬编码为32dp,非常小,可能无法舒适地容纳寻呼机和指示器。缺少添加myIndicator.onPageScrolledmyViewPager.getCurrentItem,0;也可能导致CirclePageIndicator不工作
例如:myViewPager.SetOnPageChangeListener新建ViewPager.SimpleOnPageChangeListener{
@凌驾
页面上的公共无效已选择位置{
myIndicator.onPageScrolled MyViewPage.getCurrentItem,0,0;
}
}; 不是circlepageindicator丢失了,而是页面本身没有加载。它再次“意外停止”。我在java buildpath中添加了您的库项目。但circlepageindicator仍然在xml设计中以灰色显示。您必须将其作为“Android”设置下的库项目添加,而不是通过Java构建路径添加。谢谢jake,它成功了。我的错误是图书馆没有被检查。我还不得不评论一些方法,比如fakedrag,它表明-不属于viewpager类。现在,我需要添加主题的指标,但它不采取的应用程序:半径,。。。同样尝试过style,除了android之外,它不需要任何其他工具:……如果你没有这些方法,那么你正在使用旧版本的支持库。使用SDK管理器进行升级。
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
MyPagerAdapter adapter=new MyPagerAdapter();
ViewPager myPager=(ViewPager)findViewById(R.id.myfivepanelpager);
myPager.setAdapter(adapter);
myPager.setCurrentItem(2);
CirclePageIndicator titleIndicator = (CirclePageIndicator)findViewById(R.id.indicator);
titleIndicator.setViewPager(myPager);
}