我们如何从这个java类调用Fragment?

时间:2017-04-03 08:00:57

标签: android android-fragments

我必须从这个类调用片段,并且还想在片段中发送Array列表     我在arraylist中存储firebase通知

public class DataManager{

    private static volatile DataManager dataManager;

    public DataManager() {

    }

    public static DataManager factory() {
        if (dataManager == null) {
            synchronized (DataManager.class) {
                if (dataManager == null) {
                    dataManager = new DataManager();
                }
            }
            dataManager = new DataManager();
        }
        return dataManager;
    }

    public ArrayList<NotIfModel> notIfArray = new ArrayList<>();

}

1 个答案:

答案 0 :(得分:0)

试试这个:

public DataManager(FragmentManager fragmentManager) {        
   Fragment fragment = new DetailFragment();
   fragmentManager.popBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE);
   fragmentManager.beginTransaction().add(android.R.id.content, fragment).commit();
}