I am trying to take the contents of a string that I get from another part of the program, and convert it into the name of one of my java fragment files. That name will be used to pull up that specific fragment.

For instance my file name is colors, and the string has the value colors.

I know that it is getting the correct file names, but I just don't know how to convert it to the right type needed for a fragmetn class name. I tried using Class.forName but forName is errored out with "Cannot Resolve Symbol (forName)" and it fails to compile.

Fragment fragment = null;
String selectedLocation = mMenu.get(position).getLocation();
fragment = new Class.forName(selectedLocation);

Related posts

Recent Viewed