Skip to content Skip to sidebar Skip to footer

Error:(124, 62) Error: Incompatible Types: Class Cannot Be Converted To Context

EditInformation extending to fragment. I get error in this line loading = ProgressDialog.show(EditInformation.this,'Fetching...','Wait...',false,false);, wrong 1st argument type.

Solution 1:

Change

loading = ProgressDialog.show(EditInformation.this,"Fetching...","Wait...",false,false);

to

loading = ProgressDialog.show(getActivity(),"Fetching...","Wait...",false,false);

Since you're already in a Fragment context, getActivity() shall do the trick.

Solution 2:

As you are in a fragment you will not get context by saying YourFragment.this . To achieve that you can use getActivity() method which will return context of container activity and also you can say getActivity().getApplicationContext() both will work fine.

Post a Comment for "Error:(124, 62) Error: Incompatible Types: Class Cannot Be Converted To Context"