Tenta limpar memoria.Deve estar mantendo arquivos em memoria....
Em 30/06/2013 11:23, "Felippe dos Santos Ferreira" <felippenasuacasa@gmail.com> escreveu:
-- faço o download de umas imagens
ai pego essas imagens e faço uma galeria usando as imagens
tenho cerca de 8 gallerias e cada galeria com 20 imagens
tudo isso em um grid layout...
dai quando vou exibir as imagens das gallerias da falta de moria, mais se a galeria é com pouca imagens funciona perfeitamente...
mais tb se saiu de uma galeria e entro em outra da falta de memoria
segue o codigo......
public class Galeria extends Activity {
List<String> paths;
ArrayList<Bitmap> images;
private String id;
private DataBaseAdapter dbadapter;
@Override
public void onBackPressed() {
// TODO Auto-generated method stub
finish();
super.onBackPressed();
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
getWindow().getDecorView().setSystemUiVisibility(View.STATUS_BAR_HIDDEN);
// ActionBar actionBar = getActionBar();
// actionBar.show();
// actionBar.setDisplayHomeAsUpEnabled(true);
// getActionBar().hide();
setContentView(R.layout.activity_galeria);
Log.i("teste", "on create ");
Intent intent = getIntent();
id = getIntent().getStringExtra("idacessoria"); // recebo o id da galeria para buscar as imagens
Log.i("teste", "on create "+id);
dbadapter = new DataBaseAdapter();
paths = dbadapter.getImage(getApplicationContext(), Integer.parseInt(id));//faço a busca das iamgens
Log.i("teste", "on create paths "+paths);
images = new ArrayList<Bitmap>();
for (String path : paths) {// em cada item do array de bitmap eu coloca o nome da imagem
images.add(getAssetFile(path.toString()));
Log.i("teste", "on create paths "+paths);
}
ViewPager viewPager = (ViewPager) findViewById(R.id.view_pager);
ImagePagerAdapter adapter = new ImagePagerAdapter();
viewPager.setAdapter(adapter);
}
/**
* recebe o nome do arquivo e
* @param fileName nome do arquivo
* @return imagem da galeria
*/
public Bitmap getAssetFile(String fileName) {
Bitmap bitmap = null;
try {
File filePath = getFileStreamPath(fileName);
bitmap = BitmapFactory.decodeFile(filePath.toString());
return bitmap;
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return bitmap;
}
private class ImagePagerAdapter extends PagerAdapter {
@Override
public int getCount() {
return images.size();
}
@Override
public boolean isViewFromObject(View view, Object object) {
return view == ((ImageView) object);
// return view == object;
}
@Override
public void finishUpdate(View arg0) {
// TODO Auto-generated method stub
}
@Override
public void restoreState(Parcelable arg0, ClassLoader arg1) {
// TODO Auto-generated method stub
}
@Override
public Parcelable saveState() {
// TODO Auto-generated method stub
return null;
}
@Override
public void startUpdate(View arg0) {
// TODO Auto-generated method stub
}
@Override
public Object instantiateItem(ViewGroup container, int position) {
Context context = Galeria.this;
ImageView imageView = new ImageView(context);
int padding = context.getResources().getDimensionPixelSize(R.dimen.padding_zero);
imageView.setPadding(padding, padding, padding, padding);
imageView.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
imageView.setImageBitmap(images.get(position));
// imageView.setImageBitmap(getAssetFile(paths.get(position)));
((ViewPager) container).addView(imageView);
return imageView;
}
// @Override
// public void destroyItem(ViewGroup container, int position, Object object) {
// ((ViewPager) container).removeView((ImageView) object);
// }
@Override
public void destroyItem(View collection, int position, Object o) {
View view = (View) o;
((ViewPager) collection).removeView(view);
view = null;
// final View view = (View)o;
// ((ViewPager) collection).removeView(view);
}
}
}
--
You received this message because you are subscribed to the Google Groups "Android Brasil - Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to androidbrasil-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
You received this message because you are subscribed to the Google Groups "Android Brasil - Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to androidbrasil-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
0 comentários:
Postar um comentário