如何在Android的expandablelistview中获得子项的位置 [英] How to get Position on Child item in expandablelistview in Android

查看:350
本文介绍了如何在Android的expandablelistview中获得子项的位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是第一次使用Expandable Listview适配器.我有一个问题,没有得到解决方法的唯一提示.这是我的子项目的视图

I'm working with Expandable listview adapter for first time. I have a problem and not getting i single clue that how to do it.Here is view of my child item

现在我想做的是单击待处理或分配按钮时?它获得显示在为了成功上方的文本的ID.列表中有很多项目,我不能使用onchildClick侦听器,因为我需要专注于这些按钮,并且上方的文本仅从Webservice加载.我尝试使用getChildView或getChildId,但是它给了我上一个孩子的ID,并且在未决的单击上它不会更新孩子的ID.请帮助我做到这一点.我也在适配器中使用onClick侦听器.

Now What i want to do is when i click on Pending or Assign Button ? it gets the id of textshowing above In order to success . there are many items in list and I can't use onchildClick listener because i need to focus on these buttons and the upper text is only loading from webservice. I tried to use getChildView or getChildId but It gives me id of last child and on pending click it does not update the child ID. Please help me to do this. I am using onClick listener in adapter too.

推荐答案

您可以在适配器类中实现click事件 见下面的例子 我在这里用 ListAdapter extends BaseExpandableListAdapter{

you can implement click event in adapter class see the below example here I am using ListAdapter extends BaseExpandableListAdapter{

及其ListAdapter中的重写方法,检查示例

and its the overridden method in ListAdapter , check the sample

@Override
public View getChildView(final int groupPosition, final int childPosition,
        boolean isLastChild, View convertView, ViewGroup parent) {

    final HashMap mapBinidGrp = allItms.get(groupPosition);
    final ArrayList<ArrayList<String>> itmArys = (ArrayList<ArrayList<String>>) mapBinidGrp.get(mKEY_BIN_ITEMS);
    final ArrayList<String> childText = itmArys.get(childPosition);

    if (convertView == null) {
        LayoutInflater infalInflater = (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        convertView = infalInflater.inflate(R.layout.list_row_layout, null);
    }
    TextView txtListChild6 = (TextView) convertView.findViewById(R.id.tv_one);

    txtListChild6.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            // todo
        }
    });

    return convertView;
}

这篇关于如何在Android的expandablelistview中获得子项的位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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