I simply need a Screenshot as an Bitmap of my ListView. I can't figure out how to do this. The bitmap of the screen ist than used to blur it and set is as an background in another Fragment. Where do i take Screenshot from? BaseAdapter or my Fragment which contains the ListView? or in the new Fragment that gets opened after clicking an Item in the ListView?
UPDATE:
Im calling the method inside a ViewTreeObserver from my New Fragment. The Method loadBitmapFromView
works perfectly. My Problem now is i don't know how to get hold of the ListView which i want the picture from. The Params i use mContainer,mContainer.getWidth(),mContainer.getHeight()
should change to the one from my ListView. (The params right now are form the new Fragment for testing purposes)
private void applyBlur() {
mContainer.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
@Override
public boolean onPreDraw() {
mContainer.getViewTreeObserver().removeOnPreDrawListener(this);
mContainer.buildDrawingCache();
blur(MOKListViewFragment.loadBitmapFromView(mContainer,mContainer.getWidth(),mContainer.getHeight()), mContainer);
return true;
}
});
}
This is how i call my new fragment from my BaseAdapter of the ListView which i actually want my picture from.
ImageView imageView = (ImageView) rowView.findViewById(R.id.thumb_button_1);
imageView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
MOKPagerFragment pagerFragment = new MOKPagerFragment();
FragmentTransaction fragmentTransaction = ((Activity) mContext).getFragmentManager().beginTransaction();
fragmentTransaction.setCustomAnimations(R.anim.fade_in, R.anim.fade_out);
fragmentTransaction.add(R.id.fragment_container, pagerFragment);
fragmentTransaction.addToBackStack(null);
fragmentTransaction.commit();
}
});
Sorry if this is confusing.