Android Super simple auto infinite carousel diagram Loopview

Source: Internet
Author: User
Tags tojson

Android Super simple auto infinite carousel diagram Loopview
I just need you to pass in the data.

Demo Address Https://github.com/wanghao200906/Android-LoopView

Effect implementation

1. Adding dependent libraries

2. Adding to XML

<
Com.kevin.loopview.AdLoopView
Android:id= "@+id/main_act_adloopview"
Android:layout_width= "Match_parent"
android:layout_height= "540px" >
</Com.kevin.loopview.AdLoopView >
3. Code

private void Initloopview () {
Final Adloopview Mloopview = (adloopview) This.findviewbyid (R.id.main_act_adloopview);
Get test data
Original author data sources placed in asset
String JSON = Localfileutils.getstringformasset (This, "Loopview_date.json");
My data source uses Tojson to turn data into the format required by the Libs library
String json2= Getloopdatajson ();

    Loopdata Loopdata = Jsontool.tobean (JSON, loopdata.class);    Mloopview.refreshdata (Loopdata);    Mloopview.startautoloop (); Mloopview.setonclicklistener (New Baseloopadapter.onitemclicklistener () {@Override public void Onitemclick (P Ageradapter Parent, view view, int position, int realposition) {Toast.maketext (        Loopviewactivity.this, "" + Position, Toast.length_short). Show (); }    });}    Private String Getloopdatajson () {loopparent mparent = new Loopparent ();    list<itemsentity> items = new arraylist<> ();    Itemsentity itemsentity = null;    itemsentity = new Itemsentity ();    Itemsentity.setimgurl ("http://ww1.sinaimg.cn/large/6e0519bejw1eahallpdi5j20u00f0wip.jpg");    Items.Add (itemsentity);    itemsentity = new Itemsentity ();    Itemsentity.setdesctext ("Just a test note"); Itemsentity.setimgurl ("Http://src.house.sina.com.cn/imp/imp/deal/9e/ca/e/3e072b93e939b71274b1e3ea4cc_p7_wm43,   41_mk7_c800x800.jpg "); Items.Add (itemsentity);    itemsentity = new Itemsentity ();    Itemsentity.setimgurl ("http://img0.imgtn.bdimg.com/it/u=3688416272,1545833324&fm=21&gp=0.jpg");    Items.Add (itemsentity);    itemsentity = new Itemsentity (); Itemsentity.setimgurl ("Http://src.house.sina.com.cn/imp/imp/deal/9e/ca/e/3e072b93e939b71274b1e3ea4cc_p7_wm43,    41_mk7_c800x800.jpg ");    Items.Add (itemsentity);    Mparent.setitems (items);    LOG.I ("TAG", New Gson (). ToJson (mparent)); return new Gson (). ToJson (mparent);}

Basically, if you're not satisfied with the display, you can change the library-dependent stuff.
Source code Address Https://github.com/wanghao200906/Android-LoopView
This article is only for the technical collection and for friends to share some good code

Android Super simple auto infinite carousel diagram Loopview

Related Article

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.