开发者

'Unset' Button background

I'm changing the background drawable for my buttons when they're clicked (as they trigger functions such as play/record). While playing/recording, the button glows (a different 9-patch is set as the background) and turns into a stop button. My problem is that currently I'm using:

b.setBackgroundResource(R.drawable.btn_default_normal);

to set the background ba开发者_高级运维ck again afterwards. This works, but the normal behaviour when I use setEnabled(false) is lost. After a button has been used, and reset to normal, it retains the normal background (rather than the dimmed one) when disabled. The text still changes colour though. Is there a way of 'resetting' the background of the button to default, so that it retains its normal behaviour?


Ok, I got the answer from this blog post in the end. What you have to do is create an xml document with all the different button states, and assign that rather than just an image to the background.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜