側滑選單顯示drawerLayout.openDrawer(GravityCompat.START); 關閉側滑選單drawerLayout.closeDrawer(GravityCompat.START); 關閉所有側滑選單drawerLayout.closeDrawers(); 開門大吉四個字 顯示 ui.goodLuck.attr("visibility", "visible"); 隱藏 ui.goodLuck.attr("visibility", "gone"); 按鈕事件程式碼如下
buttonIdList = ["btn_open", "btn_close", "btn_left_close", "btn_right_close"];ui.post(function () { buttonIdList.map(function (buttonId) { ui[buttonId].click(function () { setButtonClick(buttonId); }); });}, 100);function setButtonClick(buttonId) { let drawerLayout = ui.drawer_layout; switch (buttonId) { case "btn_open": //開啟側滑欄 log("btn_open"); drawerLayout.openDrawer(GravityCompat.START); //開啟左邊 drawerLayout.openDrawer(GravityCompat.END); //開啟右邊 break; case "btn_close": //關閉所有側滑欄 log("btn_close"); drawerLayout.closeDrawers(); ui.goodLuck.attr("visibility", "visible"); setTimeout(function () { ui.goodLuck.attr("visibility", "gone"); }, 2000); break; case "btn_left_close": //關閉左側 log("btn_left_close"); drawerLayout.closeDrawer(GravityCompat.START); break; case "btn_right_close": //關閉右側 log("btn_right_close"); drawerLayout.closeDrawer(GravityCompat.END); break; }}
最新評論