Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
例如,我在 XML 上制作了 imageview,我喜欢这样制作。
当我单击该图像时,图像将更改为另一个图像。
所以我想制作图像按钮,我该怎么做?
我认为 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) } });