Android 更新ExpandableListView';从AlertDialog数据中删除子对象

Android 更新ExpandableListView';从AlertDialog数据中删除子对象,android,android-activity,xamarin,xamarin.android,expandablelistview,Android,Android Activity,Xamarin,Xamarin.android,Expandablelistview,我在更新ExpandabeListView的子控件数据时遇到一些问题 我的设想是: 一,。我有一个主要活动 2.它包含一个可扩展的列表视图 3.上述ExpandableListView的子级是带有按钮和文本视图的线性布局。 4.单击上述按钮后,将显示日期选择器对话框。 5.选择日期时,我需要将所选日期设置为文本视图。 我所实施的: 一,。主活动是一个单独的文件,它扩展了活动,例如MyMainActivity.cs。 2.我已经在扩展BaseExpandableListAdapter的单独文件中为

我在更新ExpandabeListView的子控件数据时遇到一些问题

我的设想是:

一,。我有一个主要活动
2.它包含一个可扩展的列表视图
3.上述ExpandableListView的子级是带有按钮和文本视图的线性布局。
4.单击上述按钮后,将显示日期选择器对话框。
5.选择日期时,我需要将所选日期设置为文本视图。

我所实施的:

一,。主活动是一个单独的文件,它扩展了活动,例如MyMainActivity.cs。
2.我已经在扩展BaseExpandableListAdapter的单独文件中为上述expandableListView实现了适配器,比如MyListAdapater.cs
3.单击按钮后,我正在调用ShowDiloag进行活动,因为我无法从MyListAdapter.cs调用ShowDaialog,它只扩展了BaseExpandableListAdapter。
4.现在,DatePickerDialog显示在活动中
5.在日期集回调时,我正在调用Activity中的一个函数,Activity反过来调用MyListAdapter.cs中的一个函数来更新ExpandableListView中的TextView。(不起作用)

在某种程度上,我确信notifyDataSetChanged不会有帮助

请帮我解决这个问题

对不起,这段话太长了。我想到了张贴代码。但是它需要大量的编辑才能只显示有问题的代码

无论如何,如果需要,我会分享我的全部代码

代码

主要活动.cs

public class MainActivity : Activity
{
    protected override Dialog OnCreateDialog (int id)
    {
        if (id == 1111) 
        {
            DatePickerDialog datePicker = new DatePickerDialog (this, HandleDateSet, 2015, 1, 2);
            datePicker.DatePicker.MinDate = new Java.Util.Date ().Time - 1000;
            return datePicker;
        }
    }

    void HandleDateSet (object sender, DatePickerDialog.DateSetEventArgs e)
    {
        todoListAdapter.AlertDateImageButtonClicked (e.Date.ToString ("dd-MMM-yyyy"));
    }
}
ListAdapter.cs

public class ToDoListViewAdapter : BaseExpandableListAdapter
{
    public ToDoListViewAdapter (Activity newContext) : base ()
    {
        myContext = newContext;
    }

    public override View GetChildView (int groupPosition, int childPosition, bool isLastChild, View convertView, ViewGroup parent)
    {
        //other code
        inListDateTextView = view.FindViewById<TextView> (Resource.Id.DateTextView);
        dateButton = view.FindViewById<ImageButton> (Resource.Id.DateButton);
        dateButton.Click += DateImageButtonClicked;
    }

    public void DateImageButtonClicked(object sender, EventArgs e)
    {
        myContext.ShowDialog (1111);
    }

    public void AlertDateImageButtonClicked(String myDate)
    {
        inListDateTextView.Text = myDate; //not working
    }
}
公共类ToDoListViewAdapter:BaseExpandableListAdapter { public ToDoListViewAdapter(活动newContext):基本() { myContext=newContext; } 公共覆盖视图GetChildView(int-groupPosition、int-childPosition、bool-isLastChild、视图转换视图、视图组父视图) { //其他代码 inListDateTextView=view.FindViewById(Resource.Id.DateTextView); dateButton=view.findviewbyd(Resource.Id.dateButton); dateButton。单击+=单击DateImageButton; } public void DateImageButtonClicked(对象发送方,事件参数e) { myContext.ShowDialog(1111); } public void AlertDateImageButtonClicked(字符串myDate) { inListDateTextView.Text=myDate;//不工作 } }
提前谢谢

我假设onClick方法附加到ListView?如果是这样,它应该返回一个包含文本视图的视图,如果你至少可以发布你的onClick方法,这可能会有帮助Hi Shooky,我试过了,我在子视图中单击按钮,而不是整个子视图,因此不会触发childclick事件。是的,当然,我会尽快发布代码。谢谢你的回复。