I have a Gallery view in my application which is working fine. When clicking on a Gallery item, I’m displaying the full image in an ImageView. When the activity is first loaded, I want to display the first image in the full image’s ImageView programmatically, so that the user doesn’t have to click the first item in the Gallery.
— Edit —-
public void onCreate() {
//other code
ga = (Gallery)findViewById(R.id.photo_gallary);
imageView = (ImageView)findViewById(R.id.gallary__full_img);
ga.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
long arg3) {
displayFullImg(arg2);
}
});
ga.setAdapter(new ImageAdapter(this));
ga.setSelection(0);
}//onCreate
private void displayFullImg(int arg2){
Item item = pics.get(arg2);
String url = item.getImageUri();
imageView.setImageBitmap(url);
}
You can use directly