5

I have this problem ..

The method add(int, Fragment, String) in the type FragmentTransaction is not applicable for the arguments (int, Fragment, String)

when using the following code inside a FragenmtActivity

getSupportFragmentManager().beginTransaction().add(com.korovyansk.android.slideout.R.id.slideout_placeholder,  ((Fragment)new CommentsMenuFragment()), "menu").commit();

where CommentsMenuFragment implementation is :

public class CommentsMenuFragment extends Fragment {

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_comment, container, false);
        ListView lvComments = (ListView) view.findViewById(R.id.lvComments);



        return view;
    }

}
Adham
  • 63,550
  • 98
  • 229
  • 344

1 Answers1

30

Check if your CommentsMenuFragment extends from android.support.v4.app.Fragment instead of android.app.Fragment.

PaNaVTEC
  • 2,505
  • 1
  • 23
  • 36
  • 1
    it helped me, my Fragment was imported be android.app.fragment, I changed the import to android.support.v4.app, and the add error of my FragmentActivity Disapeared. Thanks @PaNaVTEC – Naveed Ahmad Jun 04 '14 at 07:44