0

我目前正在开发一个 android 应用程序。当我初始化一个 UI 元素并在 Fragment 中的 OnPageScrolled 内设置 UI 元素的内容时,它不仅在 Fragment 中起作用,而且在活动类中起作用。这是代码:

circleIndicator.setOnPageChangeListener(new OnPageChangeListener(){

                @Override
                public void onPageScrollStateChanged(int arg0) {
                    // TODO Auto-generated method stub

                }

                @Override
                public void onPageScrolled(int arg0, float arg1, int arg2) {
                    // TODO Auto-generated method stub
                    switch(arg0){
                    case 0:{

                        WorkoutDetailsFragment.this.txtNote = (EditText) getSherlockActivity().findViewById(R.id.editTextNote);
                        WorkoutDetailsFragment.this.txtNote.setText("hello");
                        WorkoutDetailsFragment.this.lstViewList1 = (ListView) getSherlockActivity().findViewById(R.id.lstViewlist1);
                        WorkoutDetailsFragment.this.lstViewList2 = (ListView) getSherlockActivity().findViewById(R.id.lstViewlist2);
                        p2 = new ArrayList<ArrayList<String>>();
                        arrayList2 = new ArrayList<String>();
                        arrayList2.add(getString(R.string.Recovery_rate));
                        arrayList2.add("");
                        p2.add(arrayList2);

                        adapter1 = new ListViewAdapterwithoutArrowHorizontal(getSherlockActivity(),
                                android.R.layout.simple_list_item_1, p2);

                        p2 = new ArrayList<ArrayList<String>>();
                        arrayList2 = new ArrayList<String>();
                        arrayList2.add(getString(R.string.Diet_Points));
                        arrayList2.add("");
                        p2.add(arrayList2);

                        adapter2 = new ListViewAdapterwithoutArrowHorizontal(getSherlockActivity(),
                                android.R.layout.simple_list_item_1, p2);
                        WorkoutDetailsFragment.this.lstViewList1.setAdapter(adapter1);

                        WorkoutDetailsFragment.this.lstViewList2.setAdapter(adapter2);
                        //LoadWorkoutResult();
                        //LoadWorkoutDetails();
                        if (adapter2.getItem(1).get(0).equals(getString(R.string.Diet_Points))
                                && extras != null) {
                            adapter2.getItem(1).remove(1);
                            adapter2.getItem(1).add(
                                    extras.getInt(getString(R.string.dietpoints)) + "");
                        }
                        Toast.makeText(getActivity(), "testing..........", Toast.LENGTH_LONG).show();
                        break;
                    }
                    case 1:{
                        //mapview = (MapView) findViewById(R.id.mapview);
                        //  break;
                    }
                    case 2:{

                        //multitouchplot = (MultitouchPlot) findViewById(R.id.multitouchPlot);
                        //series = new SimpleXYSeries();
                        //splitchart = new SplitChart(series, multitouchplot, isMile);
                        //LoadSplitChart();
                        //break;
                    }

                    }
                }

                @Override
                public void onPageSelected(int arg0) {
                    // TODO Auto-generated method stub

                }

            });

谁能知道问题出在哪里?我是否需要使用扩展 FragmentPageAdapter 的 circleppageindicator 适配器?

感谢您提前提供任何帮助。

4

1 回答 1

1

您可以根据需要自定义圆形指示器,这取决于您的需要,您想要的方式

这是我的实现

它非常适合我

注意:您还可以找到我用来创建页面指示器的库

于 2013-01-22T16:03:25.750 回答