android - ViewPager- fetching images from parse.com -


i need fetch images , texts parse database. can drawable folder problem parse. here images stored in drawable folder how can download images parse & store in folder. shall use path urls of images? please help.

public class mainactivity extends activity {  // declare variables viewpager viewpager; pageradapter adapter; string[] rank; string[] country; string[] population; int[] flag; underlinepageindicator mindicator;  @override public void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     // view viewpager_main.xml     setcontentview(r.layout.viewpager_main);      flag = new int[] { r.drawable.china, r.drawable.india,             r.drawable.unitedstates, r.drawable.indonesia,             r.drawable.brazil, r.drawable.pakistan, r.drawable.nigeria,             r.drawable.bangladesh, r.drawable.russia, r.drawable.japan };      // locate viewpager in viewpager_main.xml     viewpager = (viewpager) findviewbyid(r.id.pager);     // pass results viewpageradapter class     adapter = new viewpageradapter(mainactivity.this, rank, country,             population, flag);     // binds adapter viewpager     viewpager.setadapter(adapter);      // viewpager indicator     mindicator = (underlinepageindicator) findviewbyid(r.id.indicator);     mindicator.setfades(false);     mindicator.setviewpager(viewpager);      }  } 

viewpager adapter:

public class viewpageradapter extends pageradapter { // declare variables context context; string[] rank; string[] country; string[] population; int[] flag; layoutinflater inflater;  public viewpageradapter(context context, string[] rank, string[] country,         string[] population, int[] flag) {     this.context = context;     this.rank = rank;     this.country = country;     this.population = population;     this.flag = flag; }  @override public int getcount() {     return rank.length; }  @override public boolean isviewfromobject(view view, object object) {     return view == ((relativelayout) object); }  @override public object instantiateitem(viewgroup container, int position) {      // declare variables     textview txtrank;     textview txtcountry;     textview txtpopulation;     imageview imgflag;      inflater = (layoutinflater) context             .getsystemservice(context.layout_inflater_service);     view itemview = inflater.inflate(r.layout.viewpager_item, container,             false);      // locate imageview in viewpager_item.xml     imgflag = (imageview) itemview.findviewbyid(r.id.flag);     // capture position , set imageview     imgflag.setimageresource(flag[position]);      // add viewpager_item.xml viewpager     ((viewpager) container).addview(itemview);      return itemview; }  @override public void destroyitem(viewgroup container, int position, object object) {     // remove viewpager_item.xml viewpager     ((viewpager) container).removeview((relativelayout) object);  } } 


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -