1:
XML
<Linearlayout xmlns: Android = "http://schemas.android.com/apk/res/android"
Xmlns: Tools = "http://schemas.android.com/tools"
Android: layout_width = "match_parent"
Android: layout_height = "match_parent">
<Gallery
Android: Id = "@ + ID/imagegallery"
Android: layout_width = "fill_parent"
Android: layout_height = "match_parent"/>
</Linearlayout>
2:
Java files
Package com. example. Cloud. hdplayer2.faq;
Import Android. App. activity;
Import Android. content. context;
Import Android. OS. Bundle;
Import Android. View. view;
Import Android. View. viewgroup;
Import Android. View. viewgroup. layoutparams;
Import Android. widget. baseadapter;
Import Android. widget. Gallery;
Import Android. widget. imageview;
Public class imageshowactivity extends activity {
Private gallery imagegallery;
Private imageview image;
Private string Pos;
Private imageadapter;
Private int [] images = new int [] {R. drawable. M1, R. drawable. m2,
R. drawable. m3, R. drawable. M1, R. drawable. M1, R. drawable. M1,
R. drawable. M1 };
Protected void oncreate (bundle savedinstancestate ){
Super. oncreate (savedinstancestate );
Setcontentview (R. layout. activity_imageshow );
Imagegallery = (Gallery) findviewbyid (R. Id. imagegallery );
Imageadapter = new imageadapter (getapplicationcontext ());
Initview ();
}
Private void initview (){
Imagegallery. setadapter (imageadapter );
Imagegallery. setselection (0 );
}
Public class imageadapter extends baseadapter {
Private context mcontext;
Public imageadapter (context ){
Mcontext = context;
}
Public int getcount (){
Return images. length;
}
Public object getitem (INT position ){
Return position;
}
Public long getitemid (INT position ){
Return position;
}
Public View getview (INT position, view convertview, viewgroup parent ){
Imageview image = new imageview (mcontext );
Image. setimageresource (images [position]);
Image. setadjustviewbounds (true );
Image. setlayoutparams (new gallery. layoutparams (
Layoutparams. match_parent, layoutparams. match_parent ));
Return image;
}
}
}