我想按鈕單擊時獲取數組上的下一個項目。Android如何使用按鈕單擊獲得下一個項目
陣列是這樣的:
String[] pickupLinesItems = { "a", "b", "c" };
然後,我有本作的微調
public void onItemSelected(org.holoeverywhere.widget.AdapterView<?> parent,
View view, int position, long id) {
position = spinner.getSelectedItemPosition();
SpinnerAdapter adap = spinner.getAdapter();
if (adap.equals(pickupLinesAdapter)) {
switch (position) {
case 0:
stopPlaying();
speakMedia = MediaPlayer.create(this, R.raw.a);
break;
case 1:
stopPlaying();
speakMedia = MediaPlayer.create(this, R.raw.b);
break;
case 2:
stopPlaying();
speakMedia = MediaPlayer.create(this, R.raw.c);
break;
}
}
}
public void onClick(View v) {
// TODO Auto-generated method stub
int index = 0;
switch (v.getId()) {
case R.id.next:
// here i want to go on the next item on array
break;
case R.id.back:
// here i wanna go back one item on the array
break;
}
}
如何將我這樣做,我已經竭盡所能,並不能似乎得到它。我試圖做一個if語句,但沒有。
所以,像,如果微調是B,你需要按下一個按鈕將其更改爲C嗎? –
使用一個int值,只是遞增和遞減 –
@EmbattledSwag是 – user3204203