Code:
public void Generate(View view) {
TextView temptextview = (TextView)findViewById(R.id.txtOutputMain);
//txtOutputMain is the main Textview where I want to display results
TextView tempsets = (TextView)findViewById(R.id.edtSets);
///edtSets is where you enter the number of sets
String tempstr = tempsets.getText().toString();
//This reads whatever I type into a tempstr
int MySets = (int)Math.round(.33 * Integer.valueOf(tempstr));
//33% of the total set - take the integer value.
ArrayList<Integer> WhichSet = new ArrayList<Integer>(MySets+1);
ArrayList<String> WhichName = new ArrayList<String>(MySets+1);
//First array holds the set number that will be changed
//WhichName assigns an exercise type
Random rand = new Random();
int dummy_var = (rand.nextInt(Integer.valueOf(tempstr))) + 1;
//Randomize the total # of sets (tempstr) - this will give which set will change
StringBuilder Final_View = new StringBuilder();
//Make a string to hold set number/name information - I tried using String
for(int i=1; i==MySets; i++) {
//This will go from 1 to 33% of the sets (MySets)
while (WhichSet.indexOf(dummy_var) != -1) {
//indexOf should return -1 if the object isn't found - if it is found let's randomize
dummy_var = (rand.nextInt(Integer.valueOf(tempstr))) + 1;
//randomize because we found the same object somewhere in the string
}
WhichSet.set(i, dummy_var);
//Tried using .add(position, var) but no avail. Still nothing here.
WhichName.set(i, NumberToSetName((rand.nextInt(3)) + 1));
//See above - calls my function which simply returns a str.
Final_View.append(Integer.toString(i));
Final_View.append(": ");
Final_View.append(WhichName.get(i));
Final_View.append(System.getProperty("line.separator"));
//This was a last ditch attempt - tried using Final_View += and overloaded operators
//Still doesn't display
}
temptextview.setText(Final_View.toString());
//I can't get this to display anything. If I use a Var1="Blah" and set it as
// temptextview.setText(Var1) it works perfectly. Error must be in my set up but I can't
//find it. Setting it to something like WhichName.get(1).toString() throws an error.
}
Comments describe what should be happening. Pretty new to this so maybe I'm missing something glaring. As it is I get nothing to display when Generate is run. I did try assigning a quoted string to a String value and passing it to the temptextview.setText and it worked. Really trying to be able to add my formatting though. Trying to pass the arraylist.get(#) results in an error though I'm not certain why. I do offset the arraylist count with a +1 to keep it on a 1:1 basis with the for loop so I don't have to deal with the initial 0 index. Any help would be greatly appreciated.