问题
package com.comboyz.TantaGo;
import android.app.ListActivity;
import android.os.Bundle;
import android.widget.ArrayAdapter;
public class startMenu extends ListActivity{
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setListAdapter(new ArrayAdapter <String>(this,R.layout.startmenu,category));
}
static final String [] category= new String []{
"cinema","restuarnt","hotel","cafe","women shoping","men shoping"
};
}
i want when i click on cinema
make a new list have all names of cinema & when i press resturant it make different list have all names of the resturant and so on
回答1:
There are many different ways to do this, however I recommend doing a few changes.
First off, use a ListView element, apposed to doing ListActivity, check out this example.
Then I would suggest playing around with ViewFlipper, you can set animations to flip between the different view elements, how they work is they have a hierarchy of view elements, which can only show one at a time, so what you would do is, for example,
<ViewFlipper
.... >
<ListView
... >
<ListView
... >
<ListView
... >
</ViewFlipper>
When you get the View Flipper in your main Activity, you will set the displayed view, and as you set 0,1,2 it will flip between the list views, for example 0 could be main screen, 1 theaters, 2 restaurants, etc
回答2:
Simple you can use context menu for your list, but it just fired for long click event. For example:
registerForContextMenu(listView);
Ref http://www.dotnetexpertsforum.com/contextmenu-for-listview-longclick-event-in-android-t2034.html
来源:https://stackoverflow.com/questions/8276242/show-new-list-from-listactivitys-item-click-event