Reputation: 4328
i have an imageAdapter this is the code :
import android.content.Context;
import android.net.Uri;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.GridView;
import android.widget.ImageView;
public class ImageGalleryAdapter extends BaseAdapter {
private Context mContext;
public String[] imagePaths;
public ImageGalleryAdapter(Context c, String paths) {
mContext = c;
imagePaths = paths.split(";");
}
@Override
public int getCount() {
return imagePaths.length;
}
@Override
public Object getItem(int position) {
// TODO Auto-generated method stub
return imagePaths[position];
}
@Override
public long getItemId(int position) {
// TODO Auto-generated method stub
return 0;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
Log.i("IMAGE GALLERY ADAPTER", ""+position);
ImageView imageView = new ImageView(mContext);
imageView.setImageURI(Uri.parse(imagePaths[position]));
imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
imageView.setLayoutParams(new GridView.LayoutParams(70, 70));
return imageView;
}
}
i dont know why, but it always make my apps not responding, so i try to set Log.i to check the position in getView, and the result is position always have value = 0, whereas imagePath.length = 4.
why this always stuck in position = 0
This is the log :
07-11 18:38:25.310: I/IMAGE GALLERY ADAPTER(32154): **0**
07-11 18:38:25.313: I/MdpService(32154): [MDP INFO](32154): BpMdpService::parseJpg addr:0x53c64000, size:65536, fd:59
07-11 18:38:25.316: I/MdpService(32154): [MDP INFO](32154): BpMdpService::parseJpg reply:6
07-11 18:38:25.316: W/skia(32154): Use JPEG SW Decoder
07-11 18:38:25.484: I/dalvikvm-heap(32154): Grow heap (frag case) to 29.849MB for 19660816-byte allocation
07-11 18:38:25.726: I/SurfaceTextureClient(32154): [void android::SurfaceTextureClient::init()] debug.stc.fps: 3000 ms
07-11 18:38:25.744: E/MMUMapper(32154): fail to register MVA, unsupported format(0x5)
07-11 18:38:25.746: I/IMAGE GALLERY ADAPTER(32154): **0**
07-11 18:38:25.749: I/MdpService(32154): [MDP INFO](32154): BpMdpService::parseJpg addr:0x53c64000, size:65536, fd:60
07-11 18:38:25.751: I/MdpService(32154): [MDP INFO](32154): BpMdpService::parseJpg reply:6
07-11 18:38:25.751: W/skia(32154): Use JPEG SW Decoder
07-11 18:38:25.943: I/dalvikvm-heap(32154): Grow heap (frag case) to 48.574MB for 19660816-byte allocation
07-11 18:38:26.191: I/IMAGE GALLERY ADAPTER(32154): **0**
07-11 18:38:26.194: I/MdpService(32154): [MDP INFO](32154): BpMdpService::parseJpg addr:0x53c64000, size:65536, fd:60
07-11 18:38:26.195: I/MdpService(32154): [MDP INFO](32154): BpMdpService::parseJpg reply:6
07-11 18:38:26.195: W/skia(32154): Use JPEG SW Decoder
07-11 18:38:26.214: I/dalvikvm-heap(32154): Forcing collection of SoftReferences for 19660816-byte allocation
07-11 18:38:26.243: E/dalvikvm-heap(32154): Out of memory on a 19660816-byte allocation.
please help to solve this
Upvotes: 0
Views: 1040
Reputation: 66
It seems as though your bitmaps are causing an out of memory exeption and not being added, try re-sampling the images to be smaller
Out of memory on a 19660816-byte allocation.
are you even adding the item to the string array?
Upvotes: 2