2
BitmapFragment (아래)를 사용하는 Android FragmentPagerAdapter가 있는데 잘 작동합니다. 이제 이미지를 즉시 전환하려고합니다. 나는 ImageView를 변경하려고했지만 아무것도 변경하지 않았습니다. 그리고 그것을 밖으로 교환하는 FragmentTransaction.replace 사용하여 시도했지만 잘못된 인수 예외가 나타납니다. 나는 getImageViewAtPage()가 작동하고 "비트 맵"이 유효한 비트 맵임을 안다.Android - FragmentPagerAdapter에서 조각을 "무효화하는 방법"?
감사합니다.
private class BitmapFragment extends Fragment {
private int mPosition = 0;
private ImageView mImageView;
private BitmapFragment(int num){
super();
mPosition = num;
}
public ImageView getImageView(){
return mImageView;
}
/**
* The Fragment's UI is just a Bitmap
*/
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.fragment_bitmap, container, false);
try{
mImageView = (ImageView) v.findViewById(R.id.bitmap);
mImageView.setImageBitmap(bitmap);
}
catch(Exception e){
e.printStackTrace();
}
return v;
}
}
private void changeImage() {
/*
BitmapFragment bf = new BitmapFragment(mCurrentPageIndex);
FragmentTransaction ft = mReaderViewHandler.getSupportFragmentManager().beginTransaction();
ft.replace(R.layout.fragment_bitmap, bf);
ft.commit();
*/
ImageView v = getImageViewAtPage(mCurrentPageIndex);
try {
v.setImageBitmap(bitmap);
} catch (Exception e) {
e.printStackTrace();
}
v.invalidate();
}