我怎样才能让我的列表视图互动? [英] How can I make the my listview interactive?

查看:155
本文介绍了我怎样才能让我的列表视图互动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:结果
   Android的 - 点击的ListView HOWTO

更具体的我有一个列表视图中餐厅的名单,我想点击列表中的一家餐厅,然后被引导到具有该菜单的resturan另一个列表
谢谢

to be more specific I have a list of Restaurants in a list view and I want to click on a restaurant in the list then be directed to another list that has the menu for that resturan thanks

推荐答案

试试这个:

 listView = (ListView) findViewById(R.id.my_list_view);
 listView.setAdapter(someAdapter);
 listView.setOnItemClickListener(new OnItemClickListener() {
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            switch(position) {
            case 0:
                 Intent intent = new Intent();
                 intent.setClassName("com.test", "com.test.SubMenuActivity");
                 startActivity(intent);             
                 break;
            case 1:
                 // Do something else ...
                 break;
            // ... 
        }
    });     

这篇关于我怎样才能让我的列表视图互动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆