从 ListActivity 的项目单击事件显示新列表

发布于 2024-12-18 00:47:19 字数 670 浏览 1 评论 0原文

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

成熟稳重的好男人 2024-12-25 00:47:19

有很多不同的方法可以做到这一点,但我建议做一些改变。

首先,使用 ListView 元素,而不是执行 ListActivity,请查看 这个 示例。

然后我建议使用 ViewFlipper,您可以设置动画在不同的视图元素之间翻转,它们的工作原理是它们具有视图元素的层次结构,一次只能显示一个,所以您要做的是,例如,

<ViewFlipper
      .... >

    <ListView
         ... >

    <ListView
         ... >

    <ListView
         ... >

</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,

<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

半世蒼涼 2024-12-25 00:47:19

很简单,您可以使用列表的上下文菜单,但它只是针对长单击事件触发。例如:

  registerForContextMenu(listView);

参考 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:

  registerForContextMenu(listView);

Ref http://www.dotnetexpertsforum.com/contextmenu-for-listview-longclick-event-in-android-t2034.html

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文