Custom adapter refresh in gridview android -
i have grid view 6 cells loading in adapter. when click each cell,i going add image either taking photos or choosing images gallery.after selecting images, grid view showing empty only. though set image in 1 cell,when go cell,the previous selection gone. how make done?.. plea me. if wrong , please guide me.
if (convertview == null) { grid = new view(mcontext); grid = inflater.inflate(r.layout.fpc_document_view, null); textview textview = (textview) grid.findviewbyid(r.id.grid_text); imageview = (imageview) grid.findviewbyid(r.id.grid_image); if (filelist.size() == 0) { textview.settext(document_name_list[position].tostring()); (int = 0; <= 6; i++) { imageview.setimageresource(r.mipmap.ic_add_document); } } else { bitmap bitmapresized = null; (int = 0; < filelist.size(); i++) { if (!filelist.get(i).equals("")) { system.out.println("filelist here ,,,," + filelist.get(i).tostring()); drawable drawable = mcontext.getresources().getdrawable(r.mipmap.ic_add_document); bitmapresized = ((bitmapdrawable) drawable).getbitmap(); } else { uri selectedimageuri = uri.fromfile(filelist.get(i)); bitmapresized = imagerelatedstuff.converturitobitmap(selectedimageuri, mcontext); if (bitmapresized != null) { bitmap bitmaptemp = bitmapresized; bitmapresized = null; bitmapresized = imagerelatedstuff.getresizedbitmap(bitmaptemp, 500, 500, 0); } } imageview.setimagebitmap(imagerelatedstuff.getroundedcornerbitmap(bitmapresized, 15)); } } } else { grid = convertview; imageview = (imageview) grid.findviewbyid(r.id.grid_image); }
change code this:
if (convertview == null) { grid = new view(mcontext); grid = inflater.inflate(r.layout.fpc_document_view, null); textview textview = (textview) grid.findviewbyid(r.id.grid_text); imageview = (imageview) grid.findviewbyid(r.id.grid_image); } else { grid = convertview; imageview = (imageview) grid.findviewbyid(r.id.grid_image); } if (filelist.size() == 0) { textview.settext(document_name_list[position].tostring()); (int = 0; <= 6; i++) { imageview.setimageresource(r.mipmap.ic_add_document); } } else { bitmap bitmapresized = null; (int = 0; < filelist.size(); i++) { if (!filelist.get(i).equals("")) { system.out.println("filelist here ,,,," + filelist.get(i).tostring()); drawable drawable = mcontext.getresources().getdrawable(r.mipmap.ic_add_document); bitmapresized = ((bitmapdrawable) drawable).getbitmap(); } else { uri selectedimageuri = uri.fromfile(filelist.get(i)); bitmapresized = imagerelatedstuff.converturitobitmap(selectedimageuri, mcontext); if (bitmapresized != null) { bitmap bitmaptemp = bitmapresized; bitmapresized = null; bitmapresized = imagerelatedstuff.getresizedbitmap(bitmaptemp, 500, 500, 0); } } imageview.setimagebitmap(imagerelatedstuff.getroundedcornerbitmap(bitmapresized, 15)); } }
problem when convertview not equals null not setting image on imageview. why on 2nd cell convertview null getting image while on previous cell not null getting nothing.
Comments
Post a Comment