问题描述
我如何添加一个按钮,一个小部件,而不是打开一个活动什么的?
How do I add a button to a widget, not for opening an activity or something?
只是用于切换例如无线网络连接:)难道用的ImageButton或类似的东西做什么?我只是无法弄清楚如何添加onClickListener。
Just for toggling for example Wi-Fi :) Could it be done by a ImageButton or something like that? I just can't figure out how to add an onClickListener.
推荐答案
我已经更新了我的答案,现在我明白你试图写一个AppWidget。
I have updated my answer now that I understand you are trying to write an AppWidget.
AppWidgets只支持有限的一组查看和切换按钮是不是其中之一。意见由AppWidgets支持的名单可以在这里找到:
AppWidgets support only a limited set of Views and ToggleButton is not one of them. The list of Views supported by AppWidgets can be found here:
的
您必须使用的ImageButton和你自己记住它的切换状态。您可以根据它是否切换与否它的图像源设置为不同的图像。见的ImageButton更多信息:
You will have to use an ImageButton and remember its toggled state yourself. You can set it's image source to a different image depending on whether it is toggled or not. See ImageButton for more info:
这篇关于做一个切换按钮,窗口小部件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!