1

有没有人见过这个问题?这仅在使用 Gingerbread 设备的模拟器时发生,但是我的应用程序有一个ViewPager,当我从初始视图滑动到另一个视图并返回到初始视图时,看起来另一组图标正在覆盖Actionbar(使用ActionbarSherlock):

最初的:

在此处输入图像描述

刷卡后(通知图标变粗):

在此处输入图像描述

这不会发生在仅 Gingerbread 的 ICS+ 设备中。

浏览器:

public class Main extends SherlockFragmentActivity
{
    private static List<Integer> mIds;
    private static SparseArray<Fragment> mPageReferenceMap = new SparseArray<Fragment>();

    @Override
    public void onCreate(final Bundle icicle)
    {    
        super.onCreate(icicle);

        setContentView(R.layout.main);

        mViewPager = (ViewPager)findViewById(R.id.viewpager);
        mMyFragmentPagerAdapter = new MyFragmentPagerAdapter(getSupportFragmentManager());
        mViewPager.setAdapter(mMyFragmentPagerAdapter);

        mViewPager.setOnPageChangeListener(new OnPageChangeListener() {

            @Override
            public void onPageSelected(int position) {
                GetListingFragment().StopAnimation(); //needed to add this because the ActionView was showing on the other views when swiping
            }

            @Override
            public void onPageScrolled(int position, float offset, int offsetPixel) {
            }

            @Override
            public void onPageScrollStateChanged(int state) {

            }
        });

        mIds = new ArrayList<Integer>();

        mIds.add(0);
        mIds.add(1);
        mIds.add(2);
    }

    @Override
    public void onResume()
    { 
        super.onResume();
        ActivityCompat.invalidateOptionsMenu(this);
    }

    private ListingFragment GetKeywordsFragment()
    {       
        ListingFragment lf = (ListingFragment)getSupportFragmentManager().findFragmentById(R.id.fragmentListing);

        if (lf == null)
        {
            final MyFragmentPagerAdapter fpa = (MyFragmentPagerAdapter)mViewPager.getAdapter();
            lf = (ListingFragment)fpa.getFragment(0);
        }

        return lf;
    }

    private static class MyFragmentPagerAdapter extends FragmentStatePagerAdapter  {  

        public MyFragmentPagerAdapter(FragmentManager fm) {  
             super(fm);  
        }  

        @Override  
        public Fragment getItem(int index) {
            if (index == 0)
            {
                final ListingFragment lf = ListingFragment.newInstance();
                mPageReferenceMap.put(index, lf);
                return lf;
            }
            else
            {
                final DetailFragment df = DetailFragment.newInstance(mIds.get(index));
                mPageReferenceMap.put(index, df);
                return df;
            }
        }  

        public Fragment getFragment(int key) {
            return mPageReferenceMap.get(key);
        }

        @Override
        public int getCount() {  
             return 3;
        }
   }  
}
4

1 回答 1

1

请在ActionBarSherlock Github 上查看此问题。这个问题是已知的,截至目前,它还没有得到修复。

于 2013-03-03T04:28:04.113 回答