Galera tenho uma grid view que exibe imagens de um servidor, quando se clika na imagem eu tenho que recarregar a imagem de novo mais alguns detalhes, eu queria que invés de ter que baixar a imagem de novo, ou seja eu queria passar a imagem da imageview já carregada para outra imageview. A GridView
lv.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
//String pid = ((TextView) view.findViewById(R.id.pid)).getText().toString();
String pid = productsList.get(position).getPid();
ImageView iv = (ImageView) view.findViewById(R.id.flag);
Bitmap bitmap = ((BitmapDrawable)iv.getDrawable()).getBitmap();
DetailFragment f = new DetailFragment();
Bundle args = new Bundle();
args.putParcelable("SEU_BITMAP", bitmap);
f.setArguments(args);
boolean singlepane = MainActivity.getPane();
if(singlepane== true){
/*
* The second fragment not yet loaded.
* Load DetailFragment by FragmentTransaction, and pass
* data from current fragment to second fragment via bundle.
*/
DetailFragment detailFragment = new DetailFragment();
Fragment myListFragment = getFragmentManager().findFragmentByTag("ListFragment");
Bundle bundle = new Bundle();
bundle.putString("TAG_PID",pid);
detailFragment.setArguments(bundle);
FragmentTransaction fragmentTransaction =
getActivity().getFragmentManager().beginTransaction();
fragmentTransaction.setCustomAnimations(
R.anim.fadein, R.anim.fadeout, R.anim.fadein, R.anim.fadeout);
//This could use some improvement, but it works, hide current fragment, show new one
fragmentTransaction.hide(myListFragment);
fragmentTransaction.add(R.id.phone_container, detailFragment);
//fragmentTransaction.show(myDetailFragment);
/*
* Add this transaction to the back stack.
* This means that the transaction will be remembered after it is
* committed, and will reverse its operation when later popped off
* the stack.
*/
fragmentTransaction.addToBackStack(null);
fragmentTransaction.commit();
A Segunda fragment
getActivity().runOnUiThread(new Runnable() {
public void run() {
//creating the variables
String description;
String name;
String tags;
String downloads;
String created;
try {
//filling the variables with json content
url = (product.getString(TAG_URL));
//description = (product.getString(TAG_DESCRIPTION));
name = (product.getString(TAG_NAME));
tags = (product.getString(TAG_TAGS));
downloads = (product.getString(TAG_DOWNLOADS));
created = (product.getString(TAG_CREATED));
// Getting the tags in a gridview
stringArray = tags.split(",");
for (int i = 0; i < stringArray.length; i++)
stringArray[i] = stringArray[i].trim();
mylistview = (ExpandableHeightGridView) getActivity().findViewById(R.id.listViewTags);
ArrayAdapter<String> listAdapter = new ArrayAdapter<String>(getActivity(),
R.layout.tag_gridview_item, R.id.tagbutton,
stringArray);
mylistview.setAdapter(listAdapter);
Bitmap bitmap = getArguments().getParcelable("SEU_BITMAP");
imageView.setImageBitmap(bitmap);