【问题标题】:when I press Image, image changed to other image当我按图像时,图像变为其他图像
【发布时间】:2013-02-19 23:56:21
【问题描述】:

例如,我在 XML 上制作了 imageview,我喜欢这样制作。

当我单击该图像时,图像将更改为另一个图像。

所以我想制作图像按钮,我该怎么做?

【问题讨论】:

    标签: android image button


    【解决方案1】:

    我认为 ImageView 满足您的要求。你可以试试这段代码:

        imageView.setOnClickListener(new OnClickListener() {
    
            @Override
            public void onClick(View v) {
                                //You can set new image to the imageView by resource id, bitmap, drawable...
                imageView.setImageResource(resId)
            }
        });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-10-05
      • 1970-01-01
      • 2012-09-24
      • 1970-01-01
      • 2022-08-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多