如何获得一个按钮的背景恢复为默认(编程)? [英] How to get a Button's background back to default (programmatically)?

查看:259
本文介绍了如何获得一个按钮的背景恢复为默认(编程)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我设置一个按钮的背景下这样做:

So I'm setting a button's background doing this:

b.setBackgroundResource(R.drawable.custom_button1);

如何编程设置恢复到默认(镗灰色)的Andr​​oid按钮?有没有无需重新创建这些国家自己,我可以引用R.android.boring_grey资源标识符?可能似乎无法找到它。也许我的谷歌搜索技巧没有我。

How do I programmatically set it back to the default (boring grey) Android button? Is there a R.android.boring_grey resource identifier I can reference without recreating those states myself? Couldn't seem to find it. Maybe my Googling skills are failing me.

哦,和我尝试这样的方式:

Oh and by the way I tried this:

   b.setBackgroundResource(0);

和按钮居然消失(黑底混合?)。

And the button actually disappeared (blended with black background?).

推荐答案

您是否尝试过这个?

android.R.drawable.btn_default;

这篇关于如何获得一个按钮的背景恢复为默认(编程)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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