Here is simple gallery application.Copy and download the code and try it out.....
public class mygalleryactivity extends Activity {
Integer[] imageIDs = {
R.drawable.pic1,
R.drawable.pic2,
R.drawable.pic3,
R.drawable.pic4,
R.drawable.pic5,
R.drawable.pic6,
R.drawable.pic7
};
Gallery gallery;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
gallery=(Gallery) findViewById(R.id.Gallery01);
gallery.setAdapter(new ImageAdapter(this));
gallery.setOnItemClickListener(new OnItemClickListener()
{
public void onItemClick(AdapterView parent, View v, int position ,long id) {
// TODO Auto-generated method stub
Toast.makeText(getBaseContext(),
"pic" + (position + 1) + "selected",
Toast.LENGTH_SHORT).show();
ImageView imageView =(ImageView) findViewById(R.id.image1);
image…