我無法正確執行後退按鈕。我所見過的所有代碼片段都不適合我。當我按下後退按鈕時,我正在嘗試執行的操作是回到上一個列表。幾乎我在列表中有一個列表,我只想讓它回到之前的列表。我將如何去做這件事?這是我的列表,每個項目都有一個單獨的列表。比方說,你點擊武器,你再拿到不同的武器類型列表等後退按鈕android
final String[] weapons = getResources().getStringArray(R.array.weapons);
setListAdapter(new ArrayAdapter<String>(ffxidirectory.this, R.layout.list_item, weapons));
lv.setOnItemClickListener(new OnItemClickListener()
{
public void onItemClick(AdapterView<?> parent, View view,
int position, long id)
{
System.out.println("item clicked: "+weapons[position]);
switch(position)
{
case 0:
final String[] axes = getResources().getStringArray(R.array.axes);
setListAdapter(new ArrayAdapter<String>(ffxidirectory.this, R.layout.list_item, axes));
break;
case 1:
final String[] clubs = getResources().getStringArray(R.array.clubs);
setListAdapter(new ArrayAdapter<String>(ffxidirectory.this, R.layout.list_item, clubs));
break;
case 2:
final String[] daggers = getResources().getStringArray(R.array.daggers);
setListAdapter(new ArrayAdapter<String>(ffxidirectory.this, R.layout.list_item, daggers));
break;
case 3:
final String[] great_axes = getResources().getStringArray(R.array.great_axes);
setListAdapter(new ArrayAdapter<String>(ffxidirectory.this, R.layout.list_item, great_axes));
break;
case 4:
final String[] great_katana = getResources().getStringArray(R.array.great_katana);
setListAdapter(new ArrayAdapter<String>(ffxidirectory.this, R.layout.list_item, great_katana));
break;
case 5:
final String[] great_swords = getResources().getStringArray(R.array.great_swords);
setListAdapter(new ArrayAdapter<String>(ffxidirectory.this, R.layout.list_item, great_swords));
break;
case 6:
final String[] hand_to_hand = getResources().getStringArray(R.array.hand_to_hand);
setListAdapter(new ArrayAdapter<String>(ffxidirectory.this, R.layout.list_item, hand_to_hand));
break;
case 7:
final String[] katana = getResources().getStringArray(R.array.katana);
setListAdapter(new ArrayAdapter<String>(ffxidirectory.this, R.layout.list_item, katana));
break;
case 8:
final String[] polearms = getResources().getStringArray(R.array.polearms);
setListAdapter(new ArrayAdapter<String>(ffxidirectory.this, R.layout.list_item, polearms));
break;
case 9:
final String[] scythes = getResources().getStringArray(R.array.scythes);
setListAdapter(new ArrayAdapter<String>(ffxidirectory.this, R.layout.list_item, scythes));
break;
case 10:
final String[] staves = getResources().getStringArray(R.array.staves);
setListAdapter(new ArrayAdapter<String>(ffxidirectory.this, R.layout.list_item, staves));
break;
case 11:
final String[] swords = getResources().getStringArray(R.array.swords);
setListAdapter(new ArrayAdapter<String>(ffxidirectory.this, R.layout.list_item, swords));
break;
}
}
});