c# - Monodroid OnDismiss with Dialog Fragment -
i have custom dialogfragment
called fragment activity uses listview
.
in api 14, works fine. notifydatasetchanged()
called when save button pressed in fragment , dismissed.
in api 8, however, following error thrown after our 'save' button pressed in fragment , returns main activity.
"java.lang.illegalstateexception: content of adapter has changed listview did not receive notification. make sure content of adapter not modified background thread, ui thread. [in listview(2131099672, class android.widget.listview) adapter(class timepilot.employeesadapter)]"
i can use workaround writing update()
method in parent activity calls notfiydatasetchange()
, calling in fragment when save pressed , before dismiss()
, , works fine, feels less correct way of going this.
is there anyway implement ondimisslistener dialog fragment using monodroid? (i have seen many examples in doing android, cannot figure out monodroid).
the more curious thing error not thrown in api 14, in api 8.
employeeactivity.cs
{ protected override void oncreate(bundle bundle) { base.oncreate(bundle); // set listview setcontentview(resource.layout.employeemaster); employeesadapter = new employeesadapter(this); listview = findviewbyid<listview>(resource.id.employees); listview.adapter = employeesadapter; // dedicate buttons this.findviewbyid<button>(resource.id.button_edit).click += editbutton_click; this.findviewbyid<button>(resource.id.button_add).click += addbutton_click; this.findviewbyid<button>(resource.id.button_settings).click += settingsbutton_click; // gestures gesturedetector = new gesturedetector(this); listview.setontouchlistener(this); var x = employeesadapter.count; } void addbutton_click(object sender, eventargs e) { fragmenttransaction trans = this.supportfragmentmanager.begintransaction(); userprofilefragment userprofiledialog = new userprofilefragment(); userprofiledialog.show(trans, "profile"); } } ...
userprofilefragment.cs
... protected void save() { string name = this.name.text; string number = this.number.text; employeemanagement.getinstance().addemployee(name, number, true); employeeactivity activity = (employeeactivity)this.activity; //activity.update(); dismiss(); } ...
Comments
Post a Comment