In bello example i am getting arrays as extras and i am i have created one array imagePath[]
which stores paths of all selected images from gridview but my problem is that when i does
it for first image in gridview then it works fine but when i select another image or
public class ShowImages extends Activity {
String title1[],title[],imagePath[];
Bitmap[] mResources;
int cnt=0,j=0;
ImageView iv;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.layoutxml);
iv=(ImageView)findViewById(R.id.imageView1);
Bundle extras = getIntent().getExtras();
title1 = getIntent().getExtras().getStringArray("imageArray");
for(int i=0;i<title1.length;i++){
if(title1[i] != null){
cnt++;
}
}
imagePath=new String[cnt];
for(int i=0;i<title1.length;i++){
if(title1[i] != null){
if(j<cnt){
imagePath[j]=title1[i];
j++;
}
}
}
// Toast.makeText(getApplicationContext(),String.valueOf(cnt), Toast.LENGTH_LONG).show();
mResources=new Bitmap[cnt];
try{
for(int i=0;i<cnt;i++)
{
Toast.makeText(getApplicationContext(),imagePath[i], Toast.LENGTH_LONG).show();
File imgFile = new File(imagePath[i]);
if(imgFile.exists())
{
mResources[i] = BitmapFactory.decodeFile(imgFile.getAbsolutePath());
// iv.setImageBitmap(mResources[i]);
}
}
}
catch(Exception e){
}
}
}
multiple images in gridview it gives follwing error in logcat
05-24 17:10:12.616: E/art(3371): Throwing OutOfMemoryError "Failed to allocate a 63701004 byte allocation with 524288 free bytes and 46MB until OOM"
05-24 17:10:12.635: E/AndroidRuntime(3371): FATAL EXCEPTION: main
05-24 17:10:12.635: E/AndroidRuntime(3371): Process: com.customgallery, PID: 3371
05-24 17:10:12.635: E/AndroidRuntime(3371): java.lang.OutOfMemoryError: Failed to allocate a 63701004 byte allocation with 524288 free bytes and 46MB until OOM
Aucun commentaire:
Enregistrer un commentaire