Android可重复对话框按钮
我正在创建一个对话框,允许您多次单击图片,每次单击都会更改图片Android可重复对话框按钮,android,dialog,imageview,Android,Dialog,Imageview,我正在创建一个对话框,允许您多次单击图片,每次单击都会更改图片 final Dialog dialog = new Dialog(ViewCase.this); dialog.setContentView(R.layout.viewcase_largeimage); dialog.setCancelable(true); dialog.setCanceledOnTouchOutside(true);
final Dialog dialog = new Dialog(ViewCase.this);
dialog.setContentView(R.layout.viewcase_largeimage);
dialog.setCancelable(true);
dialog.setCanceledOnTouchOutside(true);
dialog.setTitle(name);
// show enlarged image
currPic = 1;
final ImageView imageViewLarge1 = (ImageView) dialog
.findViewById(R.id.imageViewViewCasePhotoLarge1);
imageViewLarge1.setImageBitmap(photoBitmap1);
imageViewLarge1
.setOnClickListener(new ImageView.OnClickListener() {
public void onClick(View view) {
switch (currPic) {
case 0:
imageViewLarge1
.setImageBitmap(photoBitmap1);
currPic++;
case 1:
imageViewLarge1
.setImageBitmap(photoBitmap2);
currPic++;
case 2:
imageViewLarge1
.setImageBitmap(photoBitmap3);
currPic = 0;
}
}
});
// shows the dialog
dialog.show();
}
这是我的点击监听器,我可以允许一次点击改变第二张图片,但在那之后它就停止了。有没有办法使按钮点击可重复?在
开关
块中,您应该始终使用中断代码>在每个案例之后。当开关找到正确的案例时,它不会停止执行,而是向前执行每个案例。也许这就是问题所在,你需要试一试。好吧,那之后我觉得自己很笨。现在效果很好。谢谢