Advanced Controls "Android 6"--gallery

Source: Internet
Author: User

Gallery Gallery

The gallery control is similar to the spinner class and is a subclass of the Absspinner class.

Spinner displays a vertical list selection, gallery displays a horizontal list selection box (allows the user to drag the list box horizontally)

Method

Property

Describe

Public Gallery (Context context)

Create a Gallery object

public void setspacing (int spacing)

Android:spacing

Set the display spacing between two pictures

public void Setadapter (

Spinneradapter adapter)

Set up a picture set

public void setgravity (int gravity)

Android:gravity

Set the alignment of a picture

public void Setonitemclicklistener (

Adapterview.onitemclicklistener)

Set Options Click events

Gallery ga=(Gallery) Findviewbyid (r.id.gallery);//read the picture at the end of the PNGfield[] fields = r.drawable.class. Getdeclaredfields (); List<map<string, integer>> data =NewArraylist<map<string, integer>>(); for(Field field:fields) {Map<string, integer> map =NewHashmap<string, integer>(); Try{map.put ("IMG", Field.getint (r.drawable.class));    Data.add (map); } Catch(IllegalArgumentException e) {e.printstacktrace (); } Catch(illegalaccessexception e) {e.printstacktrace (); }}simpleadapter Adapter=NewSimpleadapter ( This, data, R.layout.gallery,Newstring[] {"img"},New int[] {r.id.gaimg}); Ga.setadapter (adapter);
Gallery Section Java code

Advanced Controls "Android 6"--gallery

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.