Is there a way to do something like:
ArrayList<Class> _fragments = new ArrayList<Class>{ FirstFragmentClass.class, SecondFragmentClass.class, .... }
return new _fragments.get(iterator);
//foreach(_fragments){ ... }
P.S. I’m writing against Android API and, if I’m not mistaken, there’re slight differencies between reflection in plain java and android.
Thanks.
Yes, it’s possible, using the
Class.newInstance()method. This method invokes the no-arg constructor. Make sure your classes all have one.