任何人都可以帮助我理解android中切换按钮的drawableStateChanged()方法吗? [英] Can anyone please help me in understanding drawableStateChanged() method of toggle button in android?

查看:26
本文介绍了任何人都可以帮助我理解android中切换按钮的drawableStateChanged()方法吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

谁能帮我理解android中切换按钮的drawableStateChanged方法???我想知道为什么要使用它以及如何实现它?我在以下链接上找到了它:http://developer.android.com/reference/android/widget/ToggleButton.html.

Can anyone please help me in understanding drawableStateChanged method of toggle button in android??? I wanted to know why exactly it is used for and how to implement it?? I found it on following link: http://developer.android.com/reference/android/widget/ToggleButton.html.

推荐答案

来自阅读文档,其中指出:

from reading through the documentation which states:

This function is called whenever the state of the view changes in 
such a way that it impacts the state of drawables being shown.

似乎每当需要重绘组件时框架都会调用此函数,您可以覆盖它以(例如)执行重绘组件时需要执行的应用程序特定逻辑,例如手动绘制组件顶部的某些内容,或者更改字体或执行使用 stock 属性无法执行的操作.

it seems that this function will be called by the framework whenever the component needs to be redrawn and you can override it to (for example) perform so application specific logic which you need to do when the component is redrawn, like manually drawing something over the top of the component, or changing the font or doing something which is not possible using the stock attributes.

这个问题有一个示例,说明如何实施它.

This question has an example of how you might implement it.

这篇关于任何人都可以帮助我理解android中切换按钮的drawableStateChanged()方法吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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