我有一组8张图片,我想按顺序逐个展示它们。单击按钮后,将显示下一个图像。
我可以在imageview中加载我的图像。1.我找不到如何在单击按钮时更改图像。2.如何在程序中进行更改,使图像可滚动和缩放。
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>发布于 2011-08-08 23:22:20
您的按键呼叫的onClickLister中的
YourImageView.setImageBitmap(YourBitmap);
发布于 2011-08-08 23:16:43
有关缩放帖子的信息,请参阅this ImageView。至于如何在单击按钮时更改图像,我建议您阅读here中的如何添加按钮单击侦听器。谷歌"android button onclick example“,你会发现很多例子。如果您仍然不确定如何在单击按钮时更改图像,您应该查看Android Developers Guide,它包含许多有用的信息,如处理事件、UI等。
他们也有一些很棒的教程here。
https://stackoverflow.com/questions/6984056
复制相似问题