从ListActivity的项目Click事件显示新的列表事件、项目、列表、ListActivity

2023-09-13 02:19:52 作者:不爱几个人渣怎么货比三家

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"
    };
}

我希望当我点击电影做一个新的列表有电影院和放大器的所有名称;当我preSS RESTURANT它使不同的列表有RESTURANT的所有名称等

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

推荐答案

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

There are many different ways to do this, however I recommend doing a few changes.

首先,用一个ListView元素,结合在做ListActivity,请这例。

First off, use a ListView element, apposed to doing ListActivity, check out this example.

然后,我会建议用ViewFlipper玩弄,你可以设定动画的不同视图元素,它们是如何工作的,他们有一个层次视图元素,它只能在同一时间分别用之间翻转,所以你会做什么是,例如,

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>

当你查看翻转​​你的主要活动,您将设置显示的视图,并为您设置0,1,2它会在列表视图间切换,例如0可以是主屏,1剧院,2餐厅等

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