Java 我无法让bottomnavigationview在单击其中的项目时显示新的URL。我怎样才能解决这个问题?

Java 我无法让bottomnavigationview在单击其中的项目时显示新的URL。我怎样才能解决这个问题?,java,android,android-fragments,Java,Android,Android Fragments,我已经查找了我的问题,但找不到任何能够成功解决问题的方法。我需要在片段中实现我的bottomnavigationview,因为它们包含webview,而不是主要活动。它在前一天起作用了,然后我对我的应用程序进行了一系列的大修,我不知道现在的障碍是什么 主要片段: public class MainFragment extends Fragment{ private WebView webview; private NavigationView nvDrawer; private DrawerL

我已经查找了我的问题,但找不到任何能够成功解决问题的方法。我需要在片段中实现我的bottomnavigationview,因为它们包含webview,而不是主要活动。它在前一天起作用了,然后我对我的应用程序进行了一系列的大修,我不知道现在的障碍是什么

主要片段:

public class MainFragment extends Fragment{

private WebView webview;
private NavigationView nvDrawer;
private DrawerLayout mDrawer;
private ActionBarDrawerToggle drawerToggle;
private Toolbar toolbar;

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    //returning our layout file
    //change R.layout.yourlayoutfilename for each of your fragments
    View view =  inflater.inflate(R.layout.fragment_main, container, false);
    webview = (WebView) view.findViewById(R.id.homewebView);
    webview.setWebViewClient(new CustomWebViewClient());
    webview.getSettings().setJavaScriptEnabled(true);
    webview.getSettings().setDomStorageEnabled(true);
    webview.setOverScrollMode(WebView.OVER_SCROLL_NEVER);
    webview.loadUrl(newurl);
    // Tie DrawerLayout events to the ActionBarToggle
    BottomNavigationView bottomNavigationView = (BottomNavigationView) view.findViewById(R.id.bottom_navigation);
    bottomNavigationView.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() {
        @Override
        public boolean onNavigationItemSelected(@NonNull MenuItem item) {
            switch (item.getItemId()) {
                case R.id.action_courses:
                    webview.loadUrl("https://canvas.thelatinschool.org/courses");
                    break;
                case R.id.action_calendar:
                    webview.loadUrl("https://canvas.thelatinschool.org/calendar");
                    break;
                case R.id.action_inbox:
                    webview.loadUrl("https://canvas.thelatinschool.org/inbox");
                    break;
            }
            return true;
        }
    });
    ((DrawerLocker) getActivity()).setDrawerEnabled(false);
    return view;
}
/.../
}
其xml布局:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="org.thelatinschool.canvasgrades.MainActivity">

<WebView
    android:id="@+id/homewebView"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_alignParentStart="true"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true"
    android:layout_alignParentEnd="true"
    android:layout_alignParentRight="true"
    android:layout_alignParentBottom="true"
    android:visibility="gone" />

    </RelativeLayout>


有什么建议吗?

你能更详细地阐述你的问题吗?@Akashkumar因此基本上我的底部导航栏是可见的,当我在该栏上选择一个项目时,该项目会高亮显示,但实际上什么都没有发生,片段只是保持原样。它应该做的是更改片段的webview所显示的URL,如上面所示。