我试图做一个活动,其中我有一个按钮和3 ImageView的(imgv1,imgv2,imgv3)运行不同ImageViews。点击按钮后,第一个图像(imgv1)会出现。并在2秒后,第二个imageview(img2)将出现2secs和第三imageview(imgv3)2secs。的Android ImageView的:在一定时间间隔
这里有一段代码,我正在使用处理程序。
final Button btn = (Button) findViewById(R.id.button);
btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
img1.setVisibility(View.VISIBLE);
final Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
img2.setVisibility(View.VISIBLE);
}
}, 2000);
}
});
现在我只能运行2个imageviews,我不知道如何运行第三个图像。
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/image1"
android:visibility="gone"
android:src="@drawable/wh1"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/image2"
android:visibility="gone"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"
android:src="@drawable/wh2" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/image2"
android:visibility="gone"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"
android:src="@drawable/wh2" />
在我的xml文件
这里我设置我的三个imageview的知名度了,所以当点击按钮时,他们只能是可见的。
如果有人有任何代码示例,请帮助我。我见过很多一篇关于这个单一的ImageView改变图像资源,但是这是不同于所以请帮助我..
先生它没有工作,它只显示image1。谢谢 – Dre
现在试试吧,我忘了run()方法里面的postDelayed了。 – yshahak
它的工作原理!,谢谢先生,但我想停止时,它到达第三个图像 – Dre