私はちょうどchanged the background of a ToggleButton
となりましたが、今はそれに対応するオン/オフテキストを変更したいと考えています。これを行う最も簡単な方法は何ですか?次を使用し、XMLを使用してテキストを設定するにはトグルボタンのオン/オフテキストを変更します。Android
toggleButton.setText(textOff);
// Sets the text for when the button is first created.
toggleButton.setTextOff(textOff);
// Sets the text for when the button is not in the checked state.
toggleButton.setTextOn(textOn);
// Sets the text for when the button is in the checked state.
:
のために参照してください変更することができますsamsungとhtcの電話 – Serafins
Serafins、それは正しくありません。それはサムスンとHTCの携帯電話で動作します。 – interrupt
オンとオフのテキストをプログラムで更新するとき、ボタンは新しいテキストで再描画されません。 setChecked(toggleButton.isChecked)を呼び出すことで強制的に再描画を行うことができます。ばかばかしいですが、再描画を強制するためのハックです。 [このstackoverflowの回答](http://stackoverflow.com/a/3792554/2590478)を参照してください。 – MidasLefko