0

I have a set of 8 images, i want to show them one by one in sequence. Next image will appear once a button is clicked.

I am able to load my image in imageview. 1. I cannot find how to change the image on button click 2. How to make changes in program so that image is scrobbable & zoomable.

enter code here
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"    
  android:orientation="vertical"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  android:layout_weight="1">
  <ImageView
  android:id="@+id/imageview1"
  android:gravity="center_horizontal"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  android:layout_weight="1"
  android:src="@drawable/img1"      
  android:adjustViewBounds="true"
  android:keepScreenOn="true" 
  android:scrollbarStyle="outsideOverlay"
  android:scrollbars="horizontal" android:scaleType="fitXY"/>
  <Button      
  android:layout_height="wrap_content"
  android:layout_width="fill_parent"
  android:id="@+id/button1"
  android:text="Next"/>
</LinearLayout>
Jain
  • 1
  • 1

2 Answers2

2
  1. In the onClickLister of your button call:
    YourImageView.setImageBitmap(YourBitmap);

  2. Check out this link. A great tutorial with basics about multi-touch gestures on Android, it also got an example of how to move around and pinch-zoom an image.

iDroid
  • 10,403
  • 1
  • 19
  • 27
0

For the zoom ImageView, see this post. As far as how to change images when a button is clicked, I would suggest you read how to add a button click listener from here. Google "android button onclick example" and you will find lots of examples. If you are still unsure how to change the Image upon clicking a button, you should check out the Android Developers Guide, it has lots of useful information like handling events, UI, etc...

Also they have some great tutorials here.

Community
  • 1
  • 1
Jack
  • 9,156
  • 4
  • 50
  • 75