Android Open Source Component-----Android Loopview Unlimited Auto rotate control

Source: Internet
Author: User

Android Open Source Component-----Android Loopview Unlimited Auto rotate control

2015-12-28 15:26 by Jerry Education, 32 reading, 0 reviews, Favorites, compilation

First, the introduction of components

App products in the head of the information list will have automatic rotation of advertising images, using Viewpager can be implemented but the coding is more troublesome, we can use the Loopview open source control to complete, Loopview is a powerful rotation of the large map control, And many configuration methods are available to meet your application needs

Second, the Environment configuration

If your project is built using Gradle, simply add the following line to dependencies in your Build.gradle file:

Compile ' com.kevin:loopview:1.0.4 '

Third, how to use

1. Configure the Loopview in Layout.xml

Add <com.kevin.loopview.AdLoopView> code to the layout file as follows:

<RelativelayoutXmlns:android= "Http://schemas.android.com/apk/res/android"Xmlns:tools= "Http://schemas.android.com/tools"Xmlns:kevin= "Http://schemas.android.com/apk/res-auto"Android:layout_width= "Match_parent"Android:layout_height= "Match_parent"Tools:context=". Mainactivity "><Com.kevin.loopview.AdLoopViewAndroid:id= "@+id/adloop_act_adloopview"Android:layout_width= "Match_parent" Android:layout_height=" 192DP "  Kevin:loop_interval=" 5000 "  Kevin:loop_dotmargin=" 5DP "  Kevin:loop_autoloop=" true "  Kevin:loop_dotselector=" @drawable/ad_dots_selector " Kevin:loop_layout=" @layout/ad_loopview_layout " Span style= "color: #0000ff;" >> </com.kevin.loopview.adloopview></relativelayout >             

2. Add code to activity:

PublicClass AdloopactivityExtendsActivityImplementsbaseloopadapter.onitemclicklistener{Adloopview Mloopview; @OverrideProtectedvoidOnCreate (Bundle savedinstancestate) {Super. OnCreate (Savedinstancestate); Setcontentview (R.layout.activity_adloopview); Initviews (); Initevents (); }PrivatevoidInitviews () {Mloopview =(Adloopview)This. Findviewbyid (R.id.adloop_act_adloopview); Initrotateview (); }/*** Initialize Loopview*/PrivatevoidInitrotateview () {//Set a custom layout//Mloopview.setlooplayout (r.layout.ad_loopview_layout);//Set data String JSON = Localfileutils.getstringformasset (This, "Loopview_date.json"); Loopdata Loopdata = Jsontool.tobean (JSON, Loopdata.Class);IfNull! =Loopdata) {mloopview.refreshdata (loopdata);}//Set page transition over event Mloopview.setscrollduration (2000);//Set page switch interval mloopview.setinterval (3000); }/*** Initialize Event*/PrivatevoidInitevents () {Mloopview.setonclicklistener (thispublic void Onitemclick (pageradapter parent, View view, int position, int  Realposition) {loopdata loopdata = Mloopview.getloopdata (); String URL = LoopData.items.get (position). Link; Intent Intent = new Intent (); Intent.setdata (Uri.parse ( URL)); Intent.setaction (Intent.action_view); StartActivity (Intent); } @Override protected void  OnDestroy () {super

3, the main methods involved in Localfileutils

PublicClasslocalfileutils {/*** Get Asset text content*/PublicStaticString Getstringformasset (context context, String str) {BufferedReader in =Null;Try{in =NewBufferedReader (NewInputStreamReader (Context.getassets (). open (str))); String Line; StringBuilder buffer =NewStringBuilder ();while (line = In.readline ())! =null
Iv. Main methods of Loopview
//Set Viewpager page switch time mloopview.setscrollduration (1000);//Set the rotation interval Mloopview.setinterval (3000);//Initializes the data in a collection Mloopview.setloopviewpager (list<map<string, string>>data);//Initialize the data in JSON formatMloopview.setloopviewpager (String jsondata);//Initialize data as a data entityMloopview.setloopviewpager (Loopdata rotatedata);//Refreshes the data in a collection mloopview.refreshdata (Final List<map<string, string>>data);//Refresh data as a data entityMloopview.refreshdata (Loopdata loopdata);//// get configuration of the rotated large figure data // start auto rotate //long Delaytimeinmills); // stop auto rotate // set custom layout mloopview.setlooplayout (int layoutresid)               

Jerry Education
Source:http://www.cnblogs.com/jerehedu/

Android Open Source Component-----Android Loopview Unlimited Auto rotate control

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.