Summary of AD carousel graphs in Android

Source: Internet
Author: User

Function points: Infinite carousel, Cue point follow, click Response. Implementation ideas:

1, the indicator points follow, indicating that the point is dynamically added by the code, the quantity is determined by the number of pictures.

In the Viewpager page change listener, set the state selector of the point to enable, the current page, setenable (TRUE), the non-current page is set to False. Since the picture is obtained from the network, the number is variable, so you cannot use switch to write dead, you need to set the variable record current and previous. The code is as follows:

Lladdpoint linear layout for adding indicator points

Preposition is the previous position, set to 0,newposition as the current position when initialized

int newposition =position%imageviews.size () ;/ /Use maximum value for infinite carousel, so modulo is required.
           lladdpoint.getchildat (newposition). setenabled (true)            lladdpoint.getchildat (preposition). setenabled ( False) ;

2. Turn off the carousel diagram in the OnDestroy method of activity

3, click the response in the Viewpager adapter in the Instantiateitem method set, because the picture for the network acquisition, so you can set the ID of the way to set the Click event code:

Public ObjectInstantiateitem (ViewGroup container, final int position) {
ImageView IV =Imageviews.get (Position%Imageviews.size ());
Container.addview (iv);
//Set the Click event of the picture in this method
Iv.setonclicklistener (New View.onclicklistener () {
public voidOnClick (View v) {
//Handling Jump Logic
          Toast.< Span style= "font-style:italic;" >maketext (Carouselactivity. This, " was ordered. "+position% Imageviews.size () ,toast. Length_short). Show () ;
        ) ;
      return Iv;

4, the indicator point using shape to draw the following is the size of 5DP, solid gray dots.

<shapexmlnsAndroid= "" 
android:shape= >
<solid Span style= "color: #9876aa;" >android:color=/>
<size android :height=android :width=/>

Summary of AD carousel in Android

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: 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.