Private list<map<string, string>> mlist;
Private Finalbitmap FB;
Initialize, prepare the request server
public void Initttq () {
Mlist = new arraylist<map<string, string>> ();
StringBuffer urlsb = new StringBuffer ();
Urlsb.append (Getresources (). getString (R.STRING.STR_BCPSERVICE_IP))
. Append (":")
. Append (Getresources (). getString (R.string.str_bcpservice_port))
. Append ("/mobileinterface/forum/note/home");
Executerequest (New Jsonobjectrequest (Method.post, urlsb.tostring (),
Getttqinfo (), Ttqhomeresponselistener (), Errorlistener ()));
}
Submit Request Data
Public Jsonobject Getttqinfo () {
Jsonobject jsonobject = new Jsonobject ();
try {
Jsonobject.put ("Smallcommunitycode", Smallcommunitycode);
Jsonobject.put ("mobile", regeditmobile);
Jsonobject.put ("token", token);
Jsonobject.put ("Recordnum", "3");
return jsonobject;
} catch (Exception ex) {
Ex.printstacktrace ();
}
return null;
}
Listener Server Response
Private Response.listener<jsonobject> Ttqhomeresponselistener () {
return new response.listener<jsonobject> () {
@Override
public void Onresponse (Jsonobject jsonobject) {
try {
System.out.println (Jsonobject.tostring ());
Jsonarray Jsonarr = Jsonobject.getjsonarray ("list");
for (int i = 0; i < jsonarr.length (); i++) {
Jsonobject jsonobj = Jsonarr.getjsonobject (i);
Final map<string, string> Map = new hashmap<string, string> ();
Iterator it = Jsonobj.keys ();
while (It.hasnext ()) {
String key = It.next ();
String value = jsonobj.getstring (key);
Map.put (key, value);
}
Mlist.add (map);
FB = Finalbitmap.create (getactivity ());
Fb.configloadingimage (R.drawable.ic_launcher);
Fb.configbitmaploadthreadsize (5);
Final Viewflipper Viewflipper = (viewflipper) view
. Findviewbyid (R.id.viewflipper);
try {
for (int j = 0; J < Jsonobj.length (); j + +) {
ImageView img = new ImageView (getactivity ());
Fb.display (IMG, Mlist.get (j). Get ("Titlepicpath"). toString ());
Viewflipper.addview (IMG);
Initadvertising (Viewflipper);
}
} catch (Exception ex) {
Ex.printstacktrace ();
}
}
Initttqviewflliper ();
} catch (Exception ex) {
Ex.printstacktrace ();
}
}
};
}
Perform auto play
private void initadvertising (final viewflipper viewflipper) {
Viewflipper.setautostart (TRUE); Set AutoPlay function (Click event, auto Play before)
Viewflipper.setflipinterval (2000);
if (Viewflipper.isautostart () &&!viewflipper.isflipping ()) {
Viewflipper.startflipping ();
Animation Linanim = animationutils.loadanimation (Getactivity (),
R.ANIM.PUSH_LEFT_IN); Swipe left to enter gradient effect (alpha 0.1, 1.0)
Animation Loutanim = animationutils.loadanimation (Getactivity (),
R.anim.push_left_out); Swipe left to slide the gradient effect on the right (Alpha 1.0, 0.1)
Viewflipper.setinanimation (Linanim);
Viewflipper.setoutanimation (Loutanim);
Viewflipper.setdisplayedchild (3);
Viewflipper.shownext ();
}
Get picture JSON link from the network local rotation play