我正在运行 ABS (SampleTabsDefault) 提供的示例代码。我添加了 OnPageChangeListener 如下所示,现在 TabPageIndicator 始终卡在第一个选项卡上,即使选项卡内容发生更改。难道我做错了什么?
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.simple_tabs);
mAdapter = new GoogleMusicAdapter(getSupportFragmentManager());
mPager = (ViewPager)findViewById(R.id.pager);
mPager.setAdapter(mAdapter);
mIndicator = (TabPageIndicator)findViewById(R.id.indicator);
mIndicator.setViewPager(mPager);
ViewPager.OnPageChangeListener changeListener = new ViewPager.OnPageChangeListener() {
@Override
public void onPageScrolled(int i, float v, int i1) {}
@Override
public void onPageSelected(int i) {}
@Override
public void onPageScrollStateChanged(int i) {}
};
mPager.setOnPageChangeListener(changeListener);
mIndicator.setOnPageChangeListener(changeListener);
}