android - do you ever have to add fragments to the manifest

后端 未结 2 871
清歌不尽
清歌不尽 2021-02-07 01:48

Im using a fragment that is supposed to display a webview. When I try to instantiate it from the class that uses it I get the following warning in my logcat.

02-         


        
2条回答
  •  一整个雨季
    2021-02-07 02:27

    if you want to go back from activity to Fragment try this

    proToolbar.setNavigationOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
    

    //Note: you must give an id to the Main layout of your activity e.g : searchVehicles

                ((ConstraintLayout) findViewById(R.id.searchVehicles)).removeAllViews();
                FragmentManager fragmentManager = getSupportFragmentManager();
                FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
                fragment_nearby_vehicles fnv = new fragment_nearby_vehicles();
                fragmentTransaction.add(R.id.searchVehicles, fnv).commit();
            }
        });
    

提交回复
热议问题