close


togglebutton = (ToggleButton) findViewById(R.id.togglebutton);
togglebutton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// 當按鈕第一次被點擊時候響應的事件
if (togglebutton.isChecked()) {
close();
}
// 當按鈕再次被點擊時候響應的事件
else {
open();
}
}
});

 


<ToggleButton
android:id="@+id/togglebutton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:textSize = "44sp"
android:textOn="關閉"
android:textOff="開啟"
android:layout_weight="0.32" />

 

 

 

arrow
arrow
    全站熱搜

    stockwfj3 發表在 痞客邦 留言(0) 人氣()