I am unsure of what the following line of code does?
int convertedNumber = getIntent().getIntExtra("convertedNumber", 0);
I think it is getting the int converted Number from another activity? But then how is it possible to use this number in a list view etc in the current activity?
Current Class:
public class DisplayTimesTable extends Activity {
// set up vars
TextView trace;
ListView listView;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// setting equal to text layout View
setContentView(R.layout.display);
//initialise vars
initialiseVars();
// This declares and int variable, assigns it an int value from the calling Intent if its not there it is defaulted to 0
int convertedNumber = getIntent().getIntExtra("convertedNumber", 0);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1);
int result = 0;
// loop to give list view
for (int i = 1; i <= convertedNumber; ++i)
adapter.add(convertedNumber + "x" + i + "=" + result);
listView.setAdapter(adapter);
}
/**
* method to initialise all of the buttons, textviews etc used to clean up
* the onCreate.
*/
private void initialiseVars() {
// Setting up (initialising) all the buttons text views etc from the xml
trace = (TextView) findViewById(R.id.tvTrace);
listView = (ListView) findViewById(R.id.lvTables);
}
}