底部导航视图已添加到设计支持库的第25版中.尝试过,现在使用起来要容易得多.
但我正面临按照我的应用程序要求实现它的问题.我想动态地扩展菜单资源并以编程方式更改底部导航视图的菜单项/标题.
inflateMenu(int menuResource) - 使用菜单资源标识符为底部导航视图扩充菜单.
根据文件:
inflateMenu:void inflateMenu(int resId)将菜单资源膨胀到此导航视图中. 菜单中的现有项目不会被修改或删除. 参数resId int:要膨胀的菜单资源的ID
尝试以编程方式使用此inflateMenu(int resID)方法导航视图抛出异常" 未找到资源 "
bottomNavigationView.inflateMenu(R.menu.bottom_navigation_menu);
Run Code Online (Sandbox Code Playgroud)
是否有可能在没有任何第三方库的情况下实现它?
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">
<FrameLayout
android:id="@+id/main_fragment_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/bottom_navigation" />
<android.support.design.widget.BottomNavigationView
android:id="@+id/bottom_navigation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
app:itemBackground="@color/theme_action_bar_bg"
app:itemIconTint="@color/white"
app:itemTextColor="@color/white" />
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
菜单资源:
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/nav_bar_item_dashboard"
android:enabled="true"
android:icon="@drawable/ic_nav_bar_dashboard_24px"
android:title="@string/nav_bar_item_dashboard"
app:showAsAction="ifRoom" />
<item
android:id="@+id/nav_bar_item_people"
android:enabled="true"
android:icon="@drawable/ic_nav_bar_people_24px"
android:title="@string/nav_bar_item_people"
app:showAsAction="ifRoom" />
<item
android:id="@+id/nav_bar_item_classroom"
android:enabled="true"
android:icon="@drawable/ic_nav_bar_classroom_24px"
android:title="@string/nav_bar_item_classrooms"
app:showAsAction="ifRoom" />
<item
android:id="@+id/nav_bar_item_manage"
android:enabled="true"
android:icon="@drawable/ic_nav_bar_manage_24px"
android:title="@string/nav_bar_item_manage"
app:showAsAction="ifRoom" /> …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用隐式意图ACTION_SEND将其他应用程序中的图像共享到我的应用程序.
在从Chrome浏览器共享搜索图像时,应用会收到内容URI的意图,如下所示:
content://com.android.chrome.FileProvider/images/screenshot/1457448067808912906311.jpg
如何从此类内容URI中获取文件路径?所有其他应用程序,如Facebook,Google +都在这样做.我正在使用FileChooser获取其他类型的内容URI的文件路径(例如,来自Gallery).
在没有太多帮助的情况下到处寻找.有人可以建议如何使用这些内容URI吗?