更新切换按钮选中状态会出错
Updating togglebutton cheched state gives error
我有这个 ToggleButton
<ToggleButton
android:id="@+id/PlaymusicToggleButton"
android:layout_width="30dp"
android:layout_height="30dp"
android:textOn=""
android:textOff=""
android:layout_weight="0"
android:background="@drawable/mediabutton"
android:layout_marginRight="10dp"
android:layout_centerVertical="true" />
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="true" android:state_pressed="true" android:drawable="@drawable/b_st" /> //currently pressed turning the toggle on
<item android:state_pressed="true" android:drawable="@drawable/b_st" /> //currently pressed turning the toggle off
<item android:state_checked="true" android:drawable="@drawable/b_st" /> //not pressed default checked state
<item android:drawable="@drawable/b_pl" /> //default non-pressed non-checked
我正在尝试通过函数更新选中的值
private void UpdatePlayer(int _music){
if (_music== 0)
{
music.Playing = true;
//playmusicToggleButton.RequestLayout ();
playmusicToggleButton.Checked = true;
但是我收到了这个奇怪的错误
[ResourceType] No package identifier when getting value for resource number 0x000000
并且 UpdatePlayer 的其余部分没有加载,这个错误是关于什么的?
我在片段的开头定义了切换按钮
public class ControlPanel : ListFragment, SeekBar.IOnSeekBarChangeListener
{
ToggleButton playmusicToggleButton;
我在 OnCreateView
上为其分配了一个值
playmusicToggleButton = view.FindViewById<ToggleButton> (Resource.Id.PlaymusicToggleButton);
尝试这样做:
playmusicToggleButton = (ToggleButton) findViewById(R.id.playmusicToggleButton);
playmusicToggleButton.setChecked(true);
我有这个 ToggleButton
<ToggleButton
android:id="@+id/PlaymusicToggleButton"
android:layout_width="30dp"
android:layout_height="30dp"
android:textOn=""
android:textOff=""
android:layout_weight="0"
android:background="@drawable/mediabutton"
android:layout_marginRight="10dp"
android:layout_centerVertical="true" />
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="true" android:state_pressed="true" android:drawable="@drawable/b_st" /> //currently pressed turning the toggle on
<item android:state_pressed="true" android:drawable="@drawable/b_st" /> //currently pressed turning the toggle off
<item android:state_checked="true" android:drawable="@drawable/b_st" /> //not pressed default checked state
<item android:drawable="@drawable/b_pl" /> //default non-pressed non-checked
我正在尝试通过函数更新选中的值
private void UpdatePlayer(int _music){
if (_music== 0)
{
music.Playing = true;
//playmusicToggleButton.RequestLayout ();
playmusicToggleButton.Checked = true;
但是我收到了这个奇怪的错误
[ResourceType] No package identifier when getting value for resource number 0x000000
并且 UpdatePlayer 的其余部分没有加载,这个错误是关于什么的?
我在片段的开头定义了切换按钮
public class ControlPanel : ListFragment, SeekBar.IOnSeekBarChangeListener
{
ToggleButton playmusicToggleButton;
我在 OnCreateView
上为其分配了一个值playmusicToggleButton = view.FindViewById<ToggleButton> (Resource.Id.PlaymusicToggleButton);
尝试这样做:
playmusicToggleButton = (ToggleButton) findViewById(R.id.playmusicToggleButton);
playmusicToggleButton.setChecked(true);