android ListView 嵌入Switch控件后,如何通过按键选中Switch 20
1个回答
2017-08-20
展开全部
adroidstudioswitch控件的用法如下:Switchsc=(Switch)findViewById(R.id.switch1);sc.setOnCheckedChangeListener(newCompoundButton.OnCheckedChangeListener(){@OverridepublicvoidonCheckedChanged(CompoundButtoncompoundButton,booleanb){if(b){Toast.makeText(getApplicationContext(),"on",Toast.LENGTH_SHORT).show();}else{Toast.makeText(getApplicationContext(),"off",Toast.LENGTH_SHORT).show();}}});
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询