我有两个按钮:btn1,btn2.它们使用相同的背景图像:pic1.png.
当我在Ontouch事件中更改第一个按钮btn1的背景时,代码如下
ontouch_Action(VIEw v, MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_DOWN) { TextVIEw tv = (TextVIEw) v; int color = tv.getCurrentTextcolor(); int r = (color) & 0xFF; int g = (color >> 8) & 0xFF; int b = (color >> 16) & 0xFF; int a = (color >> 24) & 0xFF; tv.setTextcolor(color.argb(50, r, g, b)); //The other uses the same background image buttons may also change } else if (event.getAction() == MotionEvent.ACTION_UP) { int color = tv.getCurrentTextcolor(); int r = (color) & 0xFF; int g = (color >> 8) & 0xFF; int b = (color >> 16) & 0xFF; int a = (color >> 24) & 0xFF; tv.setTextcolor(color.argb(255, r, g, b)); //The other uses the same background image buttons may also change }}
第二个按钮:btn2,背景也可以更改,并且更改是随机的.
如何避免第二个按钮更改?
解决方法:
将ontouchEvent的代码更改为
int color = button1.getCurrentTextcolor();int r = (color) & 0xFF;int g = (color >> 8) & 0xFF;int b = (color >> 16) & 0xFF;int a = (color >> 24) & 0xFF;button1.setTextcolor(color.argb(DOWN_Alpha, r, g, b));
总结 以上是内存溢出为你收集整理的我有两个按钮:“ btn1,btn2”,当我更改btn1 alpha的背景时,btn2将随机更改全部内容,希望文章能够帮你解决我有两个按钮:“ btn1,btn2”,当我更改btn1 alpha的背景时,btn2将随机更改所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)