PhotoVIewAttacher和PIcasso解开片段更改的图片

时间:2015-07-15 13:23:09

标签: android android-fragments imageview picasso

好吧,所以,我已经将photoviewattacher和picasso实现到一个imageview中,当我滑动图像1将图片更改为图像2并尝试返回时,图像1仍然放大了我离开的位置。怎么解决这个?这是代码:

private PhotoViewAttacher mAttacher;

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Inflate the layout resource that'll be returned
    View rootView = inflater.inflate(R.layout.fragment_katalozi_slike, container, false);

    // Get the arguments that was supplied when
    // the fragment was instantiated in the
    // CustomPagerAdapter
    Bundle args = getArguments();
    final ImageView imageView = (ImageView) rootView.findViewById(R.id.imageViewAdapterZaListanjeKataloga);
    mAttacher = new PhotoViewAttacher(imageView);
    Callback imageLoadedCallback = new Callback() {

        @Override
        public void onSuccess() {
            if (mAttacher != null) {
                mAttacher.update();
            } else {
                mAttacher = new PhotoViewAttacher(imageView);
            }
        }

        @Override
        public void onError() {
            // TODO Auto-generated method stub

        }
    };

    Picasso.with(getActivity()).load(args.getString("url")).placeholder(R.drawable.load).error(R.drawable.error).into(imageView, imageLoadedCallback);

    ((TextView) rootView.findViewById(R.id.brojStranaNaSliciKataloga)).setText(String.valueOf(args.getInt("trenutnaStranica")) + "/" + String.valueOf(args.getInt("konacanBrojStranica")));
    ImageButton imageButton = (ImageButton) rootView.findViewById(R.id.shareButtonKatalozi);
    ImageButton locirajMe = (ImageButton) rootView.findViewById(R.id.locirajButtonKatalozi);
    final String zaShare = args.getString("linkKataloga");

    locirajMe.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            getLatLng(String.valueOf(Static.prodavci.getId()));
        }
    });

    imageButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            shareIt(zaShare);
        }
    });

    return rootView;
}

1 个答案:

答案 0 :(得分:0)

你做

@Override
public void onDestroyView() {
    super.onDestroyView();
    mAttacher.cleanup();

}

为我工作。