替换片段时出错

Error replacing Fragment

我用一个库制作了一个库activity。 这个图书馆是图书馆: https://github.com/mikepenz/AboutLibraries

问题是,如果我尝试替换我创建的片段(我创建的是正确的,我很确定),我会收到一个错误消息

这是activity

public class LibrariesActivity extends AppCompatActivity {

    public static AppCompatActivity activity;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_libraries);

        // Set up the action bar.
        Toolbar toolbar = (Toolbar) findViewById(R.id.barlibraries); // Attaching the layout to the toolbar object
        toolbar.setNavigationIcon(R.drawable.ic_back);
        toolbar.setTitle(R.string.libraries_title);
        toolbar.setNavigationOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });


        LibsFragment fragment = new LibsBuilder()
                .withLibraries("gitty_reporter", "appintro", "aboutlibraries") // definitions in strings.xml
                .withExcludedLibraries("androideasingfunctions")
                .withAutoDetect(true)
                .withLicenseShown(true)
                .withVersionShown(false)
                .withListener(new LibsConfiguration.LibsListener() {
                    @Override
                    public void onIconClicked(View view) {

                    }

                    @Override
                    public boolean onIconLongClicked(View view) {
                        return false;
                    }


                    @Override
                    public boolean onLibraryAuthorClicked(View v, Library library) {
                        return true;
                    }

                    @Override
                    public boolean onLibraryBottomClicked(View v, Library library) {
                        return true;
                    }

                    @Override
                    public boolean onLibraryAuthorLongClicked(View v, Library library) {
                        return true;
                    }

                    @Override
                    public boolean onLibraryBottomLongClicked(View v, Library library) {
                        return true;
                    }


                    @Override
                    public boolean onLibraryContentClicked(View v, Library library) {
                        return false;
                    }

                    @Override
                    public boolean onExtraClicked(View v, Libs.SpecialButton specialButton) {
                        return false;
                    }

                    @Override
                    public boolean onLibraryContentLongClicked(View v, Library library) {
                        return true;
                    }


                })
                .fragment();

        FragmentManager fragmentManager = getSupportFragmentManager();
        fragmentManager.beginTransaction.replace(R.id.about_libraries_container,fragment).commit();
    }

}

当我尝试替换时,我得到

error: expected at this line:

fragmentManager.beginTransaction().replace(R.id.about_libraries_container,fragment).

Error in the "()"

怎么了? 我搜索了很多,但还没有找到解决方案。 将不胜感激,谢谢

LibsFragment 扩展 android.app.Fragment,但您使用的 android.support.v4.app.FragmentManager 仅适用于 android.support.v4.app.Fragment.

这个库包含一个 LibsFragment 扩展 android.support.v4.app.Fragment - LibsSupportFragment.

解决方案是将LibsFragment替换为LibsSupportFragment,将.fragment()替换为.supportFragment()。有关此 here.

的更多信息