android - 将显示和隐藏按钮添加到 BottomNavigationView
问题描述
我有这个代码;
<android.support.design.internal.BottomNavigationItemView
android:layout_height="wrap_content"
android:layout_width="match_parent">
<ListView
android:id="@+id/list_time"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:divider="#E0E0E0"
android:dividerHeight="4px" />
</android.support.design.internal.BottomNavigationItemView>
我想在这个 ItemView 中添加一个带有“显示”和“隐藏”按钮的栏。当我点击显示它会显示ListView,当它隐藏它会隐藏这个ListView。我可以做吗?
解决方案
答案中已经给出了显示和隐藏功能,所以我将添加“带有显示和隐藏按钮的栏”的示例
<android.support.design.internal.BottomNavigationItemView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="2"
android:background="#123123">
<Button
android:id="@+id/btn_show"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Show" />
<Button
android:id="@+id/btn_hide"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Hide" />
</LinearLayout>
<ListView
android:id="@+id/list_time"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:divider="#E0E0E0"
android:dividerHeight="4px" />
</android.support.design.internal.BottomNavigationItemView>
然后使用其他答案应用按钮的 onclick 功能。
推荐阅读
- javascript - addEventListener 不工作。错误说 main2.js:1 Uncaught TypeError: Cannot read property 'addEventListener' of null at main2.js:1
- reactjs - 尝试导入错误:“Space”未从“antd”导出
- python - discord.py 中的命令对象
- c - 如何替换同一文件中的单词?
- c# - 显示警告消息后关闭应用程序(注销)
- bootstrap-4 - symfony 4 bootstrap 和 tablesorter 与 webpack encore
- javascript - 在没有 onlick 的情况下调用 javascript 函数
- python - suiteCRM API 调用返回 401
- java - 为什么我的 JPanel 不显示颜色或形状
- javascript - 使用 chrome 扩展从网页中抓取 Javascript 文件