FragmentTransaction类型中的方法add(int,Fragment,String)不适用于参数(int,Fragment,String)

时间:2013-03-20 07:34:36

标签: android fragment android-fragmentactivity

我有这个问题..

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

FragenmtActivity

中使用以下代码时
getSupportFragmentManager().beginTransaction().add(com.korovyansk.android.slideout.R.id.slideout_placeholder,  ((Fragment)new CommentsMenuFragment()), "menu").commit();

其中CommentMenuFragment的实现是:

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;
    }

}

1 个答案:

答案 0 :(得分:29)

检查您的CommentsMenuFragment是否从android.support.v4.app.Fragment而不是android.app.Fragment扩展。