Android Sliding effect Entry (ii) Gallery

Source: Internet
Author: User
Tags resource

Gallery is an official Android View Container class, inherited from the Absspinner class, to achieve page sliding effects.

From the above inheritance relationship, we can see that the Absspinner class inherits from Adapterview, so we can customize the implementation adapter to populate the Gallery container's data.

This example fills the picture data of the gallery container by implementing a adapter of its own, looking at the effect first:

Activity

Import android.app.Activity;     
Import Android.os.Bundle;     
Import Android.view.View;     
Import Android.widget.AdapterView;     
Import Android.widget.Gallery;     
         
Import Android.widget.Toast;     
        public class Galleryactivity extends activity {@Override public void onCreate (Bundle savedinstancestate) {     
        Super.oncreate (savedinstancestate);     
         
        Setcontentview (R.layout.main);     
        Gallery Gallery = (Gallery) Findviewbyid (r.id.gallery);         Gallery.setadapter (This) (new Imageadapter);           Gallery Add imageadapter Picture resource Gallery.setonitemclicklistener (listener); Gallery Settings Click on the picture resource event} Adapterview.onitemclicklistener listener = new ADAPTERVIEW.ONITEMC Licklistener () {@Override public void Onitemclick (adapterview<?> parent, view view, int posit ion, long ID) {Toast.maketext (galleryactivity.this, "picture" + (Position + 1), Toast.length_short). Show ();     
}     
    }; }

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.