码迷,mamicode.com
首页 > 移动开发 > 详细

android FragmentPagerAdapter的“标准”配置

时间:2015-05-14 18:39:15      阅读:187      评论:0      收藏:0      [点我收藏+]

标签:

private class ImagePagerAdapter extends FragmentPagerAdapter {
 
        public List<ImageItem> fileList;
 
        public ImagePagerAdapter(FragmentManager fm, List<ImageItem> fileList) {
            super(fm);
            this.fileList = fileList;
        }
 
        @Override
        public int getCount() {
            return fileList == null 0 : fileList.size();
        }
        @Override
        public int getItemPosition(Object object) {
            return POSITION_NONE;
        }
        @Override
        public boolean isViewFromObject(View view, Object obj) {
            return view == ((Fragment) obj).getView();
        }
        @Override
        public void destroyItem(ViewGroup container, int position, Object object) {
            Fragment fragment = ((Fragment) object);
            container.removeView(fragment.getView());
            FragmentUtils.removeFragmentRecently(getSupportFragmentManager(), fragment);
        }
        @Override
        public Fragment getItem(int position) {
            String url = fileList.get(position).getActualUrl();
            return ImageDetailFragment.newInstance(url);
        }
 
    }

android FragmentPagerAdapter的“标准”配置

标签:

原文地址:http://www.cnblogs.com/Free-Thinker/p/4503820.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!