我无法正确实现后退按钮。我见过的所有代码片段都不适合我。当我按下后退按钮时,我想要做的只是回到上一个列表。几乎我在一个列表中有一个列表,我只是希望它回到上一个列表。我该怎么做呢?这是我的清单,每个项目都有一个单独的清单。假设您单击武器,然后获得不同武器类型的列表等等
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;
}
}
});