이에 대한 조언이 필요합니다. ViewPager를 사용하여 조각이 있습니다. 나는 몇 개의 이미지가 담긴 갤러리로 사용한다. 이미지는 웹에서로드되고 비트 맵 배열에 저장됩니다. instatiateItem 및 다른 방법은 현재 사용되지 않습니다조각 관리, public static viewpager
우선 사용에서..
public class GalleryPageAdapter extends PagerAdapter {
public GalleryPageAdapter(){
}
public Object instantiateItem(View collection, int position) {
}
...
//all other methods
}
하지만 ... 나는 몇 가지 조사를 만든 작동 이제 다른 게시물을 Class extending Fragment - error says make sure class name exists, is public, and has an empty constructor that is public 및 Unable to instantiate fragment make sure class name exists, is public, and has an empty constructor that is public
을 따라 오류가없는
public class sEstablecimiento extends android.support.v4.app.FragmentActivity{
static BitmapDrawable iconos[];
//load bitmaps into iconos[] from web
static class ScreenSlidePagerAdapter extends FragmentStatePagerAdapter {
static int position;
public ScreenSlidePagerAdapter(FragmentManager fm) {
super(fm);
}
@Override
public Fragment getItem(int position) {
this.position=position;
return new ScreenSlidePageFragment();
}
@Override
public int getCount() {
return iconos.length;
}
}
public static class ScreenSlidePageFragment extends Fragment {
private BitmapDrawable image;
public ScreenSlidePageFragment() {
image=iconos[ScreenSlidePagerAdapter.position];
}
@Override
public View onCreateView(LayoutInflater inflater, final ViewGroup container,
Bundle savedInstanceState) {
ViewGroup rootView =(ViewGroup)inflater.inflate(R.layout.fragment_screen_slide_page, container, false);
ImageView icono=(ImageView)rootView.findViewById(R.id.imagen);
icono.setImageDrawable(iconos[ScreenSlidePagerAdapter.position]);
return rootView;
}
}
언제나처럼 여기 클래스와 조각의 방법으로
- 내 특정 질문은 정적, 그것은 정적하는 BitmapDrawable 배열을 필요로하고 몇 images.It이 때 BitmapDrawable 배열 '널 (null)'할 괜찮 보유하고 있습니다 활동은 기억을 풀기 위해 파괴된다? (조각을 리필하고 다른 활동에서 사용)
- 마지막 코드는 정적 클래스 또는 정적 배열이 필요하지 않습니다. 그것은 권장되지 않는대로 코드를 유지하는 것이 좋습니다.
- 무엇이 비추천 버전의 코드를 유지한다는 의미입니까?
귀하의 시간과 출석보다.
내 원래의 코드는 당신이 게시 한 그대로입니다 : 여기
이미지를 표시하는 PagerAdapter를 구현하는 몇 가지 (검증되지 않은) 샘플 코드입니다. 기사 주셔서 감사합니다. 이 경우 이전 코드를 유지하고 일부 실험에서는 기본 탐색 메뉴에서 새로운 방법을 사용합니다. 감사합니다. – UrielUVD