你能帮我吗?为什么这不起作用?我怎样才能使它工作!谢谢:) 该应用程序只是总是显示“我关掉了!”。ToggleButton - >更改TextView
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ToggleButton b = (ToggleButton)findViewById(R.id.Button);
TextView t = (TextView)findViewById(R.id.Field);
if (b.isChecked() == false){
t.setText("I'm turned off!");
}
if (b.isChecked()==true)
t.setText("I'm turned on!");
}
谢谢!这对我有效:)虽然我不得不让B和T最终! – NiDev