我有一个对话框片段,它调用另一个Alert对话框。我希望当我点击第二个项目时,它们都被解雇了。
在第一个对话框中,我有这段代码:
void ListViewVerListas_ItemLongClick (object sender, AdapterView.ItemLongClickEventArgs e)
{
string[] item_eliminar;
AlertDialog.Builder alert = new AlertDialog.Builder (this.Activity);
item_eliminar = new string[]{"Eliminar"};
ArrayAdapter ListAdapter = new ArrayAdapter<String>(this.Activity, Android.Resource.Layout.SimpleListItem1, item_eliminar);
ListView lista = new ListView (this.Activity);
lista.Adapter = ListAdapter;
lista.ItemClick+= Lista_ItemClick;
alert.SetView (lista);
posicao = e.Position;
this.Activity.RunOnUiThread (() => {
alert.Show();
} );
this.Dialog.Dismiss();
}
void Lista_ItemClick (object sender, AdapterView.ItemClickEventArgs e)
{
pos = adapter.GetItemId (posicao);
string aux="";
int c = 0;
string nome="";
string auxiliar="";
foreach (var linha in Lista) {
auxiliar = linha.Split (new char[] { ' ' }) [0];
if (c != pos) {
aux += linha + System.Environment.NewLine;
} else {
nome = auxiliar;
}
c++;
}
mItems.RemoveAt (e.Position );
adapter = new Ver_listas_adapter (this.Activity,Resource.Layout.listview_row_ver_listas, mItems);
ListViewVerListas.Adapter = adapter;
var path = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal);
var filename = Path.Combine(path, "Lista_de_Listas.txt");
FileInfo fi = new FileInfo(Path.Combine(path, nome + ".txt"));
fi.Delete ();
File.WriteAllText (filename, aux);
//this.Dismiss ();
this.Dismiss();
}
我该怎么做?