It does not let me change from fragment to webfragment


I have an application which contains a list, a detail of the item in the list and a web of the item in the list.

When I click on the first item in the list, it has to take me to the data of that item (detail class of the item) and inside that item, when I press an image, I have to open the browser with the web page of that item So with all the items in the list with their different pages.

When I do the onClick method on the photo to take me to the WebViewFragment I get an error in the replace.

logoDetalle.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            Bundle bundle = getArguments();

            FragmentManager fm = getFragmentManager();
            FragmentTransaction ft = fm.beginTransaction();
            webFragment = new WebFragment();
            ft.replace(, webFragment).commit();


(The line of the callback is a test I made using interfaces that made me change from the MainActivity, which is how I change the list in detail, but it does not work with the image, do not pay attention to it)

If I change from WebViewFragment to Fragment in the class of the Web page it gives me errors of NullPointer so the failure I suppose that it is in the method of change of fragment.

Any way for me to make the change well without having to change the webFragment class from WebViewFragment to Fragment?

asked by JNDiaz8 16.12.2018 в 16:44

0 answers