java - Issue in ArrayList in android -
in app using arraylist
save string
values.these values taken asynctask
, these values set textview
in adapter.but set values second position in arraylist
.in log showing arraylist
values contains values.but while setting not display first value.code mentioned below.
indexofselectedid = photoall_id.indexof(photoid_c); (int = indexofselectedid ; < photoall_id.size(); i++) { all_postid.add(photoall_id.get(i)); url = urls.baseurl + "mobile_api.php?action=post&post_id=" + photoall_id.get(i) + "&access_token=" + accesstoken + "&user_id=" + userid; new getimage().execute(url); } (int = 0; < indexofselectedid; i++) { all_postid.add(photoall_id.get(i)); url = urls.baseurl + "mobile_api.php?action=post&post_id=" + photoall_id.get(i) + "&access_token=" + accesstoken + "&user_id=" + userid; new getimage().execute(url); } adapter = new imagepageradapter (); viewpager.setadapter(adapter); private class getimage extends asynctask<string, void, arraylist<string>> { string json = null; arraylist<string> all_data; @override protected void onpreexecute() { all_data=new arraylist<>(); showprogress("loading images...."); super.onpreexecute(); } @override protected void onpostexecute(arraylist<string> avoid) { // touchimageview.setimagebitmap(bitmap); dismissprogress(); all_url.add(avoid.get(0)); all_cap.add(avoid.get(1)); } @override protected arraylist<string> doinbackground(string... params) { jsonreader reader = new jsonreader(); json = reader.getjsonget(params[0]); if (json != null) { try { jsonobject object = new jsonobject(json); if (object.getjsonarray("posts").getjsonobject(0).getint("count") != 0) { photo_url = object.getjsonarray("posts").getjsonobject(0).getstring("photo_url"); photo_caption = object.getjsonarray("posts").getjsonobject(0).getstring("photo_caption"); } all_data.add(photo_url); all_data.add(photo_caption); } catch (jsonexception e) { e.printstacktrace(); } } return all_data; }
}
private class imagepageradapter extends pageradapter { imageview imageview;
@override public int getcount() { return all_url.size(); } @override public boolean isviewfromobject(view view, object object) { return view == object; } @override public object instantiateitem(viewgroup container, int position) { context context = fullscreenactivity.this; layoutinflater inflater = (layoutinflater)context.getsystemservice(context.layout_inflater_service); view viewlayout = inflater.inflate(r.layout.item, container, false); imageview = (imageview)viewlayout. findviewbyid(r.id.cardimage); int padding = context.getresources().getdimensionpixelsize( r.dimen.padding_medium); imageview.setpadding(padding, padding, padding, padding); imageview.setscaletype(imageview.scaletype.center_inside); log.d("caption testingggggggggfgfgf", all_upuser.get(position)); picasso.with(context).load(all_url.get(position)).into(imageview); current_postid=all_postid.get(position); string temp_cap=all_cap.get(position); image_head.settext(temp_cap); ((viewpager) container).addview(viewlayout, 0); return viewlayout; } @override public void destroyitem(viewgroup container, int position, object object) { ((viewpager) container).removeview((view) object); }
}
and log is
clickzy d/caption testing﹕ morning 01-27 12:34:05.200 3389-3389/com.wat.clickzy w/settings﹕ setting airplane_mode_on has moved android.provider.settings.system android.provider.settings.global, returning read-only value. 01-27 12:34:05.210 3389-3389/com.wat.clickzy d/caption testing﹕ lol caption testing﹕ vv 01-27 12:34:06.780 3389-4782/com.wat.clickzy d/dalvikvm﹕ gc_for_alloc freed 806k, 9% free 29169k/31980k, paused 29ms, total 29ms 01-27 12:34:06.780 3389-4782/com.wat.clickzy i/dalvikvm-heap﹕ grow heap (frag case) 31.335mb 1728016-byte allocation 01-27 12:34:06.805 3389-4782/com.wat.clickzy d/dalvikvm﹕ gc_for_alloc freed 1k, 9% free 30855k/33668k, paused 25ms, total 25ms 01-27 12:34:08.525 3389-3389/com.wat.clickzy d/caption testingggggggggfgfgf﹕ red 01-27 12:34:08.590 3389-4796/com.wat.clickzy d/dalvikvm﹕ gc_for_alloc freed 851k, 9% free 30850k/33668k, paused 46ms, total 46ms 01-27 12:34:08.590 3389-4796/com.wat.clickzy i/dalvikvm-heap﹕ grow heap (frag case) 32.976mb 1728016-byte allocation 01-27 12:34:08.630 3389-3400/com.wat.clickzy d/dalvikvm﹕ gc_for_alloc freed <1k, 8% free 32537k/35356k, paused 43ms, total 43ms 01-27 12:34:10.060 3389-3389/com.wat.clickzy d/caption testingggggggggfgfgf﹕ gleegy.
log
contains first value "goodmorning",but set textview
second value.please suggest me solution
Comments
Post a Comment