I have a problem.
I have a dialog that has an EditText. The contents of this EditText I caught and put in a ListView, the error is that my variable that receives the contents of the EditText only receives null. move contents of dialog for the listview was to be quiet
code:
{ ImageView btnAddLinha = (ImageView) objDialogAddNewLine.FindViewById(Resource.Id.btok); ImageView btnCancelar =(ImageView)objDialogAddNewLine.FindViewById(Resource.Id.btcancel); btnAddLinha.Click + = delegate { EditText txtNomedaLinha = FindViewById<EditText> (Resource.Id.txtNomedaLinha); <-- txtNomeLinha receive NULL?? Why??? Item_ListView newItem = new Item_ListView (txtNomedaLinha.Text); items.add (newItem); adapterListView AdapterListView = new (this, items); adapterListView.NotifyDataSetChanged (); MainList.Adapter = adapterListView; } }
Posts
As a guess, you should try using
objDialogAddNewLine.FindViewById<EditText>(Resource.Id.txtNomedaLinha)
, not justFindViewById<EditText>(Resource.Id.txtNomedaLinha)
.Alternatively, presumably you're using
SetContentView()
in your code. Does the layout you're using contain atxtNomedaLinha
id?Thanks, resolved!