Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我的 android 应用程序的操作栏上有一个按钮,用于切换侧边栏。问题是,我不知道用户何时单击打开侧边栏的按钮以及何时关闭它。这是因为按下后退按钮或单击侧边栏外的区域也会关闭侧边栏。那么如何使操作栏上的按钮有效地切换侧边栏的打开和关闭呢?
你的侧边栏应该有一个公共方法来返回它是否打开。或者,只需在其上调用 toggle(),它会在关闭时打开它(反之亦然)