Forum Xamarin.Android

Is GetChildView Button Event questions ExpandableListView.

KimYGKimYG USMember ✭✭
edited September 2016 in Xamarin.Android

When i click the GetChildView btnReturn once in ExpandableListView, the event occurs many times.

        View row = convertView;
        if (row == null)
        {
            row = Context.LayoutInflater.Inflate(Resource.Layout.DataListItem, null);
        }

        SqliteDataBase dbTemp;
        dbTemp = new SqliteDataBase();
        dbTemp.CreateDatabase("Example20");

        List<WorkCheckBeanPartSubmit> lstWorkCheckBeanPartSubmit;

        Button btnReturn = row.FindViewById<Button>(Resource.Id.btnReturn);

        btnReturn.Click += (s, e) =>
        {
            View innerView = null;
            innerView = Context.LayoutInflater.Inflate(Resource.Layout.WorkManagementDetailTab3Fragment, null);

            #region Sub UI
            TextView tvWorkManagementDetailTab3PartReturnCountName;
            EditText etWorkManagementDetailTab3PartReturnCount;
            Button btnWorkManagementDetailTab3PartReturnSave;

            ListView lvWorkManagementDetailTab3Fragment;
            RelativeLayout tab3layout1, tab3layout2;
            #endregion

            lstWorkCheckBeanPartSubmit = dbTemp.WorkCheckBeanPartSubmitRead();
            if (lstWorkCheckBeanPartSubmit != null)
            {
                tvWorkManagementDetailTab3PartReturnCountName = innerView.FindViewById<TextView>(Resource.Id.tvWorkManagementDetailTab3PartReturnCountName);
                etWorkManagementDetailTab3PartReturnCount = innerView.FindViewById<EditText>(Resource.Id.etWorkManagementDetailTab3PartReturnCount);
                btnWorkManagementDetailTab3PartReturnSave = innerView.FindViewById<Button>(Resource.Id.btnWorkManagementDetailTab3PartReturnSave);
                lvWorkManagementDetailTab3Fragment = innerView.FindViewById<ListView>(Resource.Id.lvWorkManagementDetailTab3Fragment);
                tab3layout1 = innerView.FindViewById<RelativeLayout>(Resource.Id.tab3layout1);
                tab3layout2 = innerView.FindViewById<RelativeLayout>(Resource.Id.tab3layout2);

                tab3layout1.Visibility = ViewStates.Gone;
                tab3layout2.Visibility = ViewStates.Visible;

                var oodapter = new WorkCheckPartSubmitListAdapter(Context, lstWorkCheckBeanPartSubmit);
                lvWorkManagementDetailTab3Fragment.Adapter = oodapter;

                AlertDialog.Builder ab = new Android.App.AlertDialog.Builder(Context);
                ab.SetView(innerView);
                AlertDialog al = ab.Create();
                al.Show();
            }
        };

        return row;

I wanna know why that event occurred many times.

Best Answer

Answers

Sign In or Register to comment.