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