Viewpager不是同时执行的

时间:2016-07-25 13:06:32

标签: android android-viewpager

以下是我用来设置视图寻呼机的代码。 我用4个寻呼机设置它

  1. 状态
  2. 照片
  3. 评分
  4. 联络点。 以下是使用

    的代码
     private void setupViewPager(ViewPager viewPager) {
    ViewPagerAdapter adapter = new ViewPagerAdapter(getSupportFragmentManager());
    adapter.addFrag(new StatusFragment(), "Status");
    adapter.addFrag(new MyOrderPhotos(), "Photos");
    adapter.addFrag(new RatingFragment(), "Rating");
    adapter.addFrag(new Contacts(), "Contact");
    viewPager.setAdapter(adapter);}
    
  5. 我使用以下代码设置标签图标

    private void setupTabIcons() {
    
        TextView tabOne = (TextView) LayoutInflater.from(this).inflate(R.layout.custom_tab, null);
        tabOne.setText("Status");
        tabOne.setGravity(Gravity.CENTER);
        tabOne.setCompoundDrawablesWithIntrinsicBounds(0, R.drawable.tab_one_selector, 0, 0);
        tabLayout.getTabAt(0).setCustomView(tabOne);
        TextView tabTwo = (TextView) LayoutInflater.from(this).inflate(R.layout.custom_tab, null);
        tabTwo.setText("Photos and Docs");
        tabTwo.setGravity(Gravity.CENTER);
        tabTwo.setCompoundDrawablesWithIntrinsicBounds(0, R.drawable.tab_two_selector, 0, 0);
        tabLayout.getTabAt(1).setCustomView(tabTwo);
    
        TextView tabThree = (TextView) LayoutInflater.from(this).inflate(R.layout.custom_tab, null);
        tabThree.setText("Rating");
        tabThree.setGravity(Gravity.CENTER);
        tabThree.setCompoundDrawablesWithIntrinsicBounds(0, R.drawable.tab_three_selector, 0, 0);
        tabLayout.getTabAt(2).setCustomView(tabThree);
    
        TextView tabFour = (TextView) LayoutInflater.from(this).inflate(R.layout.custom_tab, null);
        tabFour.setText("Point of Contact");
        tabFour.setGravity(Gravity.CENTER);
        tabFour.setCompoundDrawablesWithIntrinsicBounds(0, R.drawable.tab_four_selector, 0, 0);
        tabLayout.getTabAt(3).setCustomView(tabFour);
    }
    

    问题是视图寻呼机没有同步执行。 如果用户打开应用程序,则正在执行状态和照片。 如果用户滚动到照片,则执行评级等等。

    为什么会这样?我怎样才能解决这个问题呢?

0 个答案:

没有答案
相关问题