Fra*_*nco 9 android togglebutton android-ui
我有一个像这样定义的ToggleButton:
<ToggleButton android:text="ToggleButton" android:id="@+id/toggle"
android:layout_height="wrap_content" android:layout_width="fill_parent"></ToggleButton>
Run Code Online (Sandbox Code Playgroud)
我想以编程方式更改其状态.我尝试使用setChecked和toggle方法,但这些都不适用于我的情况.
我有持续通知,当我的活动收到通知意图时,切换按钮应设置为不检查,但它不起作用.
我在活动上这样做onResume.代码正在执行,但ToggleButton的状态不会改变.
奇怪的是,如果我调用setChecked(false)活动,onCreate它会改变按钮的状态,但不会改变onResume.我错过了什么?
谢谢.
Fra*_*nco 15
得到它了.的种类.
我有这个
protected void onResume() {
super.onResume();
Intent intent;
if ((intent = getIntent()) != null && MainActivity.STOP.equals(intent.getAction())) {
disable();
toggle.setChecked(false);
finish();
}
}
Run Code Online (Sandbox Code Playgroud)
但呼吁finish实际上并没有做任何事情.我删除它,现在它的工作原理.不知道为什么修复它.
有人在意解释?
| 归档时间: |
|
| 查看次数: |
41941 次 |
| 最近记录: |