1

I made a libraries activity with a library. This library is the library: https://github.com/mikepenz/AboutLibraries

The problem is i get ann error if i try to replace the fragment i created (i created correclty, i am quite sure)

This is the 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();
    }

}

When i try to replace i get

error: expected at this line:

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

Error in the "()"

What is wrong? I searched a lot and not found yet a solution. Help will be appreciated, thank you

galvan
  • 7,400
  • 7
  • 38
  • 55
Jonathan I
  • 240
  • 1
  • 4
  • 18

1 Answers1

1

LibsFragment extends android.app.Fragment, but you are using android.support.v4.app.FragmentManager which works only with android.support.v4.app.Fragment.

This library includes a LibsFragment that extends android.support.v4.app.Fragment - LibsSupportFragment.

The solution is to replace LibsFragment with LibsSupportFragment and .fragment() with .supportFragment(). More info on this here.

Egor Neliuba
  • 14,784
  • 7
  • 59
  • 77
  • I wrote it wrong,it was typo error here, the problem is that it says "failed to resolve symbol replace" – Jonathan I Dec 16 '15 at 20:42
  • a friend of mine did it without errors look at this https://github.com/Desno365/Desno365sMods/blob/48b228707855f41a346b2a4a441a28ec5646d607/app/src/main/java/com/desno365/mods/Activities/LibrariesActivity.java – Jonathan I Dec 16 '15 at 20:54
  • He's using version 5.2.0 of the library (an older one). Take a look at [this changelog](https://github.com/mikepenz/AboutLibraries/releases/tag/v5.3.0). – Egor Neliuba Dec 16 '15 at 20:56
  • You are right! Going to try, very usefull, thanks dude you helped me really a lot! – Jonathan I Dec 16 '15 at 20:58