トグルボタンをクリックしたときの状態の切り替えを遅らせる必要があります。私はいくつかの操作をしなければならず、別のイベントが呼び出されたときよりもトグルボタンの状態を変更する必要があります。どうやってやるの?ありがとう!
1252 次
1 に答える
4
をサブクラス化しToggleButton
、クリック処理をオーバーライドします。を使用しAsyncTask
てタスクを完了し、実際にトグルをsuper.performClick()
実行したいときに呼び出して実際のトグルを実行します。
public class MyToggleButton extends ToggleButton {
public MyToggleButton(Context context) {
super(context);
}
public MyToggleButton(Context context, AttributeSet attrs) {
super(context, attrs);
}
public MyToggleButton(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
@Override
public boolean performClick() {
// do your thing here
// only call the below line if you actually want it to happen.
return super.performClick();
}
}
于 2011-06-03T20:27:03.007 に答える