Hello,
I have the following code for a spinner:
public class MyOnItemSelectedListener implements OnItemSelectedListener {
public void onItemSelected(AdapterView<?> parent,
View view, int pos, long id) {
String TABLE_NAME = parent.getItemAtPosition(pos).toString();
int spinnerYearsPos = parent.getSelectedItemPosition();
Cursor cursor = getStats(TABLE_NAME);
showStats(cursor);
}
public void onNothingSelected(AdapterView<?> parent) {
// Do nothing.
}
}
What I would like to do is be able to pass the spinnerYearsPos variable in the above code into this method:
public void clickHandler(View v ){
if (v.getId() == R.id.TableTab) {
Intent myIntent = new Intent(getApplicationContext(), Table.class);
myIntent.putExtra("spinnerYearsPos", spinnerYearsPos);
startActivity(new Intent(getApplicationContext(), Table.class));
}
if (v.getId() == R.id.OtherStatsTab) {
startActivity(new Intent(getApplicationContext(), OtherStats.class));
}
}
At present Eclipse is underlining the spinnerYearsPos reference in red. How do I call the clickHandler method and then pass the spinnerYearsPos variable into it?