I am working with a viewpager and compiling API 23. I\'m showing a compile error in my code for the following statement, but the project does compile.
List<
I actually did this to get a reference to all the fragments:
private List<WeakReference<Fragment>> mFragList = new ArrayList<WeakReference<Fragment>>();
@Override
public void onAttachFragment (Fragment fragment) {
mFragList.add(new WeakReference(fragment));
}
public List<Fragment> getActiveFragments() {
ArrayList<Fragment> ret = new ArrayList<Fragment>();
for(WeakReference<Fragment> ref : mFragList) {
Fragment f = ref.get();
if(f != null) {
if(f.isVisible()) {
ret.add(f);
}
}
}
return ret;
}
public Fragment findFragement(String tClass) {
List<Fragment> fragments = getActiveFragments();
for (Fragment fragment : fragments) {
if (tClass.equalsIgnoreCase("Home")) {
if (fragment instanceof ToggleFragment) {
return fragment;
}
} else if (tClass.equalsIgnoreCase("Contacts")) {
if (fragment instanceof ContactFragment) {
return fragment;
}
}
}
return null;
}