我知道這是一個相當普遍的問題,但是在Google搜索幾個小時後,我找不到問題的答案。CirclePageIndicator屏幕底部
我正在使用PageViewIndicator庫。我想在佈局的底部添加圓圈指標。我正在嘗試這個,但是當應用程序打開時,它立即崩潰。當我交換CirclePageIndicator和ViewPager的地方時,它可以很好地工作,但指標顯示在活動的頂部。
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
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"
android:background="#000000"
/>
</LinearLayout>
這就是我如何初始化它在Java中
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_take_test);
mAdapter = new FragmentAdapter(getSupportFragmentManager());
mPager = (ViewPager)findViewById(R.id.pager);
mPager.setAdapter(mAdapter);
mIndicator = (CirclePageIndicator)findViewById(R.id.indicator);
mIndicator.setViewPager(mPager);
}
我怎樣才能解決這個只用LinearLayout中?
試試這個'com.viewpagerindicator.CirclePageIndicator mIndicator =(com.viewpagerindicator.CirclePageIndicator)findViewById(R.id.indicator);' – 2014-10-02 09:42:04
它不工作,正如我上面提到的,當我改變的地方尋呼機和指示器,它可以很好地工作 – 2014-10-02 09:47:58
當它崩潰時,你會得到什麼錯誤/異常? – 2014-10-02 09:52:01