The ultimate goal is to add additional fragments to the program without modifying the code. I want to do this by changing the array-values of the resource files(not at run-time). One resource-array has the spinner values, another has the fragment file names. The order that they are listed in the resource file is how they correlate: So the first spinner array-String correlates to the first fragment TypedArray item and so on.
I wrote a simple class so that I can keep a correlation between my spinner values and the fragments that the spinner value represents. This is the class:
import android.support.v4.app.Fragment;
public class SensorList {
int index;
String name;
Fragment sensorFrag;
SensorList(){
name="";
sensorFrag=null;
index=0;
}
}
I want to populate an instance of this class with values from resource TypedList. That is where I am having problems. This is my code of that so far. The last line is clearly in error as it doesn't have an index for the 'add'.
public ArrayList<SensorList> sensorList = new ArrayList<SensorList>();
Resources res = getResources();
sensorList.(res.obtainTypedArray(R.array.sensor_frag_names)); //This line is a problem.
Am I going about this the wrong way? Is there a cast that I can apply. If this isn't clear, let me know. Thanks.