I have Main activity:
public class GeneralActivity extends ActionBarActivity {
...
}
I have another class in which I create a drawer, I bring to the required parameters. But when I want to move to a different fragment when you click on the menu item, then IDE writes that there is no method getSupportFragmentManager ().
public class DrawerClass {
public static void drawer(final Activity activity, Toolbar toolbar) {
...
result.setOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
@Override
public boolean onItemClick(View view, int i, IDrawerItem iDrawerItem) {
Log.d("POSITION", "position = " + i);
switch (i) {
....
case 5:
Toast.makeText(activity, R.string.drawer_item_journal, Toast.LENGTH_SHORT).show();
JournalFragment journalFragment = new JournalFragment();
FragmentTransaction transaction = getSupportFragmentManager()
.beginTransaction();
transaction.replace(R.id.profile_fragment_layout, journalFragment);
transaction.commit();
break;
}
return false;
}
});
I have an error on the line FragmentTransaction transaction = getSupportFragmentManager()
And I don't know how fix it.
I use this drawer in several classes, so I created a separate class in order to avoid duplication of code