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> mFragList = new ArrayList>();
@Override
public void onAttachFragment (Fragment fragment) {
mFragList.add(new WeakReference(fragment));
}
public List getActiveFragments() {
ArrayList ret = new ArrayList();
for(WeakReference ref : mFragList) {
Fragment f = ref.get();
if(f != null) {
if(f.isVisible()) {
ret.add(f);
}
}
}
return ret;
}
public Fragment findFragement(String tClass) {
List 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;
}