添加监听子节点的扩展列表项目 [英] Adding listener to child nodes in Expandable List Item

查看:115
本文介绍了添加监听子节点的扩展列表项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用的教程给予code
http://mylifewithandroid.blogspot.com/2010/12/expandable -list和 - checkboxes.html
我重视的ExpandableListView的图像

I have used a code given in tutorial http://mylifewithandroid.blogspot.com/2010/12/expandable-list-and-checkboxes.html I have attached an image of the ExpandableListView

SimpleExpandableListAdapter expListAdapter =
        new SimpleExpandableListAdapter(
            this,
            createGroupList(),  
            R.layout.child_row, 
            new String[] { "CityName" },
            new int[] { R.id.childname },       
            createChildList(),  
            R.layout.child_row, 
            new String[] { "citydetails", "city" }, 
            new int[] { R.id.childname, R.id.city}  
        );

    setListAdapter( expListAdapter );

我需要关于如何监听器添加到各个子节点例如点击地址应该将用户到另一个活动的一些code例子。
期待你的回复。
谢谢。

I need some code example on how to add listeners to individual child nodes for example clicking on Address should take the user to another activity. Looking forward to your reply. thanks.

推荐答案

您也可以有你的活动覆盖了onChildClick方式:

You can also have your activity override the the onChildClick method:

@Override
public boolean onChildClick(ExpandableListView expandableListView, View view, int groupPosition, int childPosition, long id) {
    //implement logic to start the appropriate activity for this child.
}

从Android开发人员网站:<一href=\"http://developer.android.com/reference/android/widget/ExpandableListView.OnChildClickListener.html\"相对=nofollow> onChildClick 。

我也建议下载 API演示。您可以了解更多关于设置它这里

I also recommend downloading the API Demos. You can learn more on setting it up here.

这篇关于添加监听子节点的扩展列表项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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