java - SwipeView change the content of 2 pages -


i've created new activity swipe views, , added code.

i have 2 swipeable pages, same content, how can change content of second swipe page.

do have create new activity or redirect xml?

import java.util.locale;  import android.graphics.bitmap; import android.support.v7.app.actionbaractivity; import android.support.v4.app.fragment; import android.support.v4.app.fragmentmanager; import android.support.v4.app.fragmentpageradapter; import android.os.bundle; import android.support.v4.view.viewpager; import android.view.layoutinflater; import android.view.menu; import android.view.menuitem; import android.view.view; import android.view.viewgroup; import android.widget.imageview; import android.widget.textview;  import com.nostra13.universalimageloader.core.displayimageoptions; import com.nostra13.universalimageloader.core.imageloader; import com.nostra13.universalimageloader.core.imageloaderconfiguration; import com.nostra13.universalimageloader.core.assist.failreason; import com.nostra13.universalimageloader.core.listener.imageloadinglistener;   public class listitemclicked extends actionbaractivity {  static bundle extras;  sectionspageradapter msectionspageradapter; static imageloader imageloader; static displayimageoptions options;     viewpager mviewpager;  @override protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.list_item_clicked);       msectionspageradapter = new sectionspageradapter(getsupportfragmentmanager());      extras = getintent().getextras();      mviewpager = (viewpager) findviewbyid(r.id.pager);     mviewpager.setadapter(msectionspageradapter);      //setup imageloader, we'll use display our images     imageloaderconfiguration config = new imageloaderconfiguration.builder(this).build();     imageloader = imageloader.getinstance();     imageloader.init(config);      //setup options imageloader handle caching us.     options = new displayimageoptions.builder()             .cacheinmemory()             .cacheondisc()             .build();  }   @override public boolean oncreateoptionsmenu(menu menu) {     // inflate menu; adds items action bar if present.     getmenuinflater().inflate(r.menu.menu_main_activity2, menu);     return true; }  @override public boolean onoptionsitemselected(menuitem item) {     int id = item.getitemid();      return id == r.id.action_settings || super.onoptionsitemselected(item);  }    public class sectionspageradapter extends fragmentpageradapter {      public sectionspageradapter(fragmentmanager fm) {         super(fm);     }      @override     public fragment getitem(int position) {         return placeholderfragment.newinstance(position + 1);     }      @override     public int getcount() {         return 2;     }      @override     public charsequence getpagetitle(int position) {         locale l = locale.getdefault();         switch (position) {             case 0:                 return getstring(r.string.title_section4).touppercase(l);             case 1:                 return getstring(r.string.title_section5).touppercase(l);         }         return null;     } }   public static class placeholderfragment extends fragment {       private static final string arg_section_number = "section_number";       public static placeholderfragment newinstance(int sectionnumber) {         placeholderfragment fragment = new placeholderfragment();         bundle args = new bundle();         args.putint(arg_section_number, sectionnumber);         fragment.setarguments(args);         return fragment;     }      public placeholderfragment() {     }      @override     public view oncreateview(layoutinflater inflater, viewgroup container,                              bundle savedinstancestate)     {          view rootview = inflater.inflate(r.layout.fragment_list_item_clicked, container, false);           textview pdate = (textview) rootview.findviewbyid(r.id.textview);         pdate.settext( extras.getstring("pdate") );           textview ptitle = (textview) rootview.findviewbyid(r.id.section_label);         ptitle.settext(extras.getstring("pname"));           textview pntext = (textview) rootview.findviewbyid(r.id.textview2);         pntext.settext( extras.getstring("ptext"));             //setup listener can use swtich loading indicator image once it's ready         imageloadinglistener listener = new imageloadinglistener(){                @override             public void onloadingstarted(string arg0, view arg1) {                 // todo auto-generated method stub              }              @override             public void onloadingcancelled(string arg0, view arg1) {                 // todo auto-generated method stub              }              @override             public void onloadingcomplete(string arg0, view arg1, bitmap arg2) {                 // i/ndicator.setvisibility(view.invisible);                // iconimg.setvisibility(view.visible);             }             @override             public void onloadingfailed(string arg0, view arg1, failreason arg2) {                 // todo auto-generated method stub              }          };          //load image , use our options caching handled.         final imageview iconimg = (imageview) rootview.findviewbyid(r.id.imageview);         imageloader.displayimage( extras.getstring("pimage"), iconimg, options, listener);            return rootview;     } }  } 

thanks!

based on page number placeholder fragment can set new content


Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -