android - ImageView black background on some devices -
i have listview contains images (each row), width of each image match_parent , height 0.4 of width.
now works fine, except on big screen devices (like nexus 7...), instead of images see black background
here listview adapter
public class adapter extends arrayadapter<string>{ int width = 0; private final activity context; private final string[] title; private final int[] img; public plansadapter(activity context, string[] title, int[] img) { super(context, r.layout.listsingle, title); this.context = context; this.title = title; this.img = img; } @override public view getview(int position, view convertview, viewgroup parent) { layoutinflater inflater = context.getlayoutinflater(); convertview = inflater.inflate(r.layout.listsingle, null, true); textview title = (textview) convertview.findviewbyid(r.id.text); title.settext(title[position]); imageview img = (imageview) convertview.findviewbyid(r.id.img); img.setimageresource(img[position]); width = ((activity) getcontext()).getwindowmanager().getdefaultdisplay().getwidth(); double = (double) 44/96; img.getlayoutparams().height = (int) (a*width); relativelayout bghover = (relativelayout )convertview.findviewbyid(r.id.bghover); bghover.getlayoutparams().height = (int) (a*width); return convertview; } }
in next activity use same code , see image.
width = getwindowmanager().getdefaultdisplay().getwidth(); double = (double) 44/96; img.getlayoutparams().height = (int) (a*width);
i think device memory isn't big enough show images
here logcat
eglsurfaceattrib not implemented
dropping event due no window focus: keyevent { action=action_down, keycode=keycode_alt_right, scancode=100, metastate=meta_alt_on|meta_alt_right_on, flags=0x8, repeatcount=497, eventtime=242910, downtime=216396, deviceid=1, source=0x301 }
dropping event due no window focus: keyevent { action=action_down, keycode=keycode_alt_right, scancode=100, metastate=meta_alt_on|meta_alt_right_on, flags=0x8, repeatcount=498, eventtime=242960, downtime=216396, deviceid=1, source=0x301 }
gc_for_alloc freed 1461k, 8% free 18275k/19844k, paused 6ms, total 6ms
i think device runs out of memory or this. i've made photos load in background , works fine.
Comments
Post a Comment