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

后端 未结 2 865
清歌不尽
清歌不尽 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:34

    No don't add it to your manifest. You never need to add fragments to your manifest.

    Do you create an Intent somewhere to start the WebActivity? How is it brought to the screen, that is probably where your problem lies.

    EDIT

    This is your problem:

     Intent showContent = new Intent(getApplicationContext(),
                WebFrag.class);
     startActivity(showContent);
    

    You can't start a Fragment as an Activity, you'll have to wrap the fragment in an Activity that extends FragmentActivity

提交回复
热议问题