android FragmentPagerAdapter的“标准”配置

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)