switch控件的简单问题
xml:<Switchandroid:id="@+id/switchSave"android:layout_width="wrap_content"android:lay...
xml:
<Switch
android:id="@+id/switchSave"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="提醒" />
Activity onCreate:
Switch sc=(Switch)findViewById(R.id.switchSave);
sc.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
if (b){
Log.e("ying","switch");
}else {
Log.e("ying","switch_close");
}
}
});
错误提示:
请教下这怎样改啊? 展开
<Switch
android:id="@+id/switchSave"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="提醒" />
Activity onCreate:
Switch sc=(Switch)findViewById(R.id.switchSave);
sc.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
if (b){
Log.e("ying","switch");
}else {
Log.e("ying","switch_close");
}
}
});
错误提示:
请教下这怎样改啊? 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询