1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
|
class Toto extends Activity
{
int currentData;
public void onCreate(Bundle b)
{
[...]
currentData = readData();
spinner.setAdapter(...);
spinner.setSelection(currentData);
spinner.setOnItemSelectedListener(new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
if (position != Toto.this.currentData)
Toto.this.onDataChanged(position);
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
});
}
public void onDataChanged(int position)
{
currentData = position;
writeData();
}
} |
Partager