5

我有这个问题..

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

在 a 中使用以下代码时FragenmtActivity

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

其中 CommentsMenuFragment 实现是:

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

}
4

1 回答 1

29

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

于 2013-03-20T07:38:46.703 回答