Get picture JSON link from the network local rotation play

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.