从 ListActivity 的项目单击事件显示新列表
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"
};
}
我希望当我单击“电影院”时创建一个新列表,其中包含电影院和电影院的所有名称。当我按餐厅时,它会列出不同的列表,其中包含餐厅的所有名称等
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
有很多不同的方法可以做到这一点,但我建议做一些改变。
首先,使用 ListView 元素,而不是执行 ListActivity,请查看 这个 示例。
然后我建议使用 ViewFlipper,您可以设置动画在不同的视图元素之间翻转,它们的工作原理是它们具有视图元素的层次结构,一次只能显示一个,所以您要做的是,例如,
当您在主 Activity 中获取视图翻转器时,您将设置显示的视图,当您设置 0,1,2 时,它将在列表视图之间翻转,例如 0 可能是主屏幕,1 剧院,2 餐厅, ETC
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,
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
很简单,您可以使用列表的上下文菜单,但它只是针对长单击事件触发。例如:
参考 http://www.dotnetexpertsforum .com/contextmenu-for-listview-longclick-event-in-android-t2034.html
Simple you can use context menu for your list, but it just fired for long click event. For example:
Ref http://www.dotnetexpertsforum.com/contextmenu-for-listview-longclick-event-in-android-t2034.html