Android ExpandableListview:为子行中的imageview添加clicklistener,同时保持行单击

Android ExpandableListview:为子行中的imageview添加clicklistener,同时保持行单击,android,list,xamarin,click,listeners,Android,List,Xamarin,Click,Listeners,我有一个可扩展的列表视图。在这些列表视图中有组视图和子视图。 在childview中,有一个ImageView 当我在imageview的适配器中添加clicklistener时,OnChildClicked(在listview上)的侦听器不再工作 如何同时收听两个ClickEvents? 在指示符号本身上添加onclick也是很好的,但是我不知何故需要groupposition和childposition,我不知道怎么做 这是tagList.ChildClick的事件处理程序: void Ta

我有一个可扩展的列表视图。在这些列表视图中有组视图和子视图。 在childview中,有一个ImageView

当我在imageview的适配器中添加clicklistener时,OnChildClicked(在listview上)的侦听器不再工作

如何同时收听两个ClickEvents? 在指示符号本身上添加onclick也是很好的,但是我不知何故需要groupposition和childposition,我不知道怎么做

这是tagList.ChildClick的事件处理程序:

void TagList_ChildClick (object sender, ExpandableListView.ChildClickEventArgs e)
    {
        //if (adapter.IsIndicatorClicked()) 
        //{
            TagVO tag = tagsCollection [e.GroupPosition].Tags [e.ChildPosition];

            tag.Selected = !tag.Selected;
            if (tag.Selected) 
            {
                _mySelectionController.SaveLocalTag (tag);
            } 
            else
                _mySelectionController.RemoveLocalTag (tag);


            adapter.NotifyDataSetChanged ();
        //} else

    }
适配器中的GetChildView方法:请参阅“Console.Writeline(“测试”) (此方法已激发,但上面的处理程序未激发)

public override View GetChildView(int-groupPosition、int-childPosition、bool-isLastChild、View-convertView、View-group-parent)
{
TagHolder TagHolder=null;
TagVO tag=tags[groupPosition].tags[childPosition];
if(convertView==null)
{
convertView=_activity.LayoutInflater.Inflate(Resource.Layout.tagListItem,null);
标记持有人=新标记持有人();
tagHolder.AddTagBtn=convertView.findviewbyd(Resource.Id.AddTagBtn);
tagHolder.TagIndicatorBtn=convertView.FindViewById(Resource.Id.tagIndicator);
tagHolder.TagNameTv=convertView.findviewbyd(Resource.Id.TagNameTv);
tagHolder.tagindicatorv=convertView.FindViewById(Resource.Id.tagindicatorv);
tagHolder.tagindicator v.单击+=委派
{
控制台写入线(“测试”);
};
tagHolder.TagNameTv.SetTypeface(TypeFaceLoader.get(_activity.ApplicationContext,“font/DINPro Regular.otf”)、Android.Graphics.TypefaceStyle.Normal);
Tag=tagHolder;
} 
其他的
{
tagHolder=(tagHolder)convertView.Tag;
}
tagHolder.TagNameTv.Text=tag.Name;
如果(标记[groupPosition]。标记[childPosition]。选中)
{
tagHolder.AddTagBtn.SetBackgroundColor(Color.ParseColor(“#44c4d1”);
tagHolder.TagIndicatorBtn.SetBackgroundColor(Color.ParseColor(“#44c4d1”);
tagHolder.TagNameTv.SetTextColor(Color.White);
tagHolder.tagIndicatorIv.SetImageDrawable(_activity.Resources.GetDrawable(Resource.Drawable.check));
} 
其他的
{
tagHolder.AddTagBtn.SetBackgroundDrawable(_activity.Resources.GetDrawable(Resource.Drawable.articleBg));
tagHolder.TagIndicatorBtn.SetBackgroundDrawable(_activity.Resources.GetDrawable(Resource.Drawable.articleBg));
tagHolder.TagNameTv.SetTextColor(Color.ParseColor(#848484”);
tagHolder.tagIndicatorIv.SetImageDrawable(_activity.Resources.GetDrawable(Resource.Drawable.plus));
}
返回视图;
}

告诉我们你的代码是什么,我们可以更好地帮助你。否则,我们只会猜测出什么地方出了问题。我已经更新了问题,告诉我们你的代码是什么,我们可以更好地帮助你。否则,我们只会猜测出什么地方出了问题。我已经更新了问题,告诉我们你的代码是什么,我们可以更好地帮助你。其他rwise,我们只是在猜测到底出了什么问题。我已经更新了这个问题
 public override View GetChildView (int groupPosition, int childPosition, bool isLastChild, View convertView, ViewGroup parent)
    {
        TagHolder tagHolder=null;
        TagVO tag = tags [groupPosition].Tags [childPosition];

        if (convertView == null) 
        {
            convertView = _activity.LayoutInflater.Inflate (Resource.Layout.tagListItem, null);
            tagHolder = new TagHolder ();

            tagHolder.AddTagBtn = convertView.FindViewById<ViewGroup> (Resource.Id.addTagBtn);
            tagHolder.TagIndicatorBtn = convertView.FindViewById<ViewGroup> (Resource.Id.tagIndicator);
            tagHolder.TagNameTv = convertView.FindViewById<TextView> (Resource.Id.tagNameTv);
            tagHolder.tagIndicatorIv = convertView.FindViewById<ImageView> (Resource.Id.tagIndicatorIv);
            tagHolder.tagIndicatorIv.Click+= delegate 
            {
                Console.WriteLine("test");  
            };

            tagHolder.TagNameTv.SetTypeface (TypeFaceLoader.get (_activity.ApplicationContext, "fonts/DINPro-Regular.otf"),Android.Graphics.TypefaceStyle.Normal);

            convertView.Tag = tagHolder;
        } 
        else 
        {
            tagHolder = (TagHolder) convertView.Tag;
        }

        tagHolder.TagNameTv.Text = tag.Name;

        if (tags [groupPosition].Tags [childPosition].Selected) 
        {
            tagHolder.AddTagBtn.SetBackgroundColor (Color.ParseColor ("#44c4d1"));
            tagHolder.TagIndicatorBtn.SetBackgroundColor (Color.ParseColor ("#44c4d1"));
            tagHolder.TagNameTv.SetTextColor (Color.White);
            tagHolder.tagIndicatorIv.SetImageDrawable(_activity.Resources.GetDrawable( Resource.Drawable.check));
        } 
        else 
        {
            tagHolder.AddTagBtn.SetBackgroundDrawable (_activity.Resources.GetDrawable( Resource.Drawable.articleBg));
            tagHolder.TagIndicatorBtn.SetBackgroundDrawable (_activity.Resources.GetDrawable( Resource.Drawable.articleBg));
            tagHolder.TagNameTv.SetTextColor (Color.ParseColor ("#848484"));
            tagHolder.tagIndicatorIv.SetImageDrawable(_activity.Resources.GetDrawable( Resource.Drawable.plus));
        }



        return convertView;
    }