图像查看更改源图像时pressed [英] Change source image for image view when pressed

查看:173
本文介绍了图像查看更改源图像时pressed的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有很多的图像按钮滚动视图。我想改变图像的图像按钮时,它的pssed $ P $。事情是,我想要的形象留到另一幅图像按钮pssed $ P $。这就是为什么我不能用一个选择。什么是实现自己的最佳做法是什么?

I have a scroll view with lots of image buttons. I want to change the image for an image button when it's pressed. The thing is that I want the image to remain until another image button is pressed. That's why I couldn't use a selector. What is the best practice to achieve his?

最好的问候

推荐答案

您想这样做。

ImageButton Demo_button = (ImageButton)findViewById(R.id.firstimage);

// when you click this demo button
Demo_button.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
  Demo_button.setImageResource(R.drawable.secondimage);
 }
}

试试这个。 (更新setset设置)

Try this. (updated setset to set)

这篇关于图像查看更改源图像时pressed的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆