0
I have a Listview
, one EditText
and a Buttom
. When I click on the button I want it to play what it has on ListView
in a ArrayList
, so that I can enter what was written in the EditText
in the ArrayList
and then use it to carry the ListView
.
In short, that would be:
ArrayList = ListView;
ArrayList.add(valor);
ListView.setAdapter(new ArrayAdapter(this, ..., ArrayList));
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center_horizontal" >
<ImageButton
android:id="@+id/imgBtIncluirPessoaTarefa"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/edtPessoaEditarTarefa"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:src="@android:drawable/ic_input_add" />
<EditText
android:id="@+id/edtPessoaEditarTarefa"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_toLeftOf="@id/imgBtIncluirPessoaTarefa"
android:ems="10"
android:hint="Pessoa"
android:inputType="textPersonName" >
<requestFocus />
</EditText>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<ListView
android:id="@+id/listaPessoasEditar"
android:layout_width="match_parent"
android:layout_height="130sp" >
</ListView>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center_horizontal" >
<ImageButton
android:id="@+id/imgBtIncluirTarefa"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/edtTarefaEditarTarefa"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:src="@android:drawable/ic_input_add" />
<EditText
android:id="@+id/edtTarefaEditarTarefa"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_toLeftOf="@id/imgBtIncluirTarefa"
android:ems="10"
android:hint="Tarefa"
android:inputType="textPersonName" >
</EditText>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<ListView
android:id="@+id/listaTarefasEditar"
android:layout_width="match_parent"
android:layout_height="130sp" >
</ListView>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<Button
android:id="@+id/button1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Button" />
</RelativeLayout>
Where that
Button
is? Want to get the whole list or just a line? If it’s a line, how do you know the line?– Wakim
I want to get all the lines!
– César Alves
Could include your layout?
– Wakim
it seems that it returns an Adapter, but error to convert to arrayList
– César Alves
You want the value that’s in
Adapter
or the current value of the list items? It is possible to iterate over theAdapter
and use thegetItem
, since unfortunately theArrayAdapter
does not provide access to the list directly. But by accessinggetItem
, you are accessing the values you used to popular the elements and not the current.– Wakim
I want to take what’s in Listview!
– César Alves
Got it @Césaralves, I will try to prepare an answer as soon as I have less curled up, even today.
– Wakim
I could do it here bro! Thank you so much! @Wakim
– César Alves
if you can, put the code you solved as a question and accept it, it can help other people who might have this problem.
– Wakim
@Césaralves Consider posting the solution to this problem and help others with it.
– Ismael
I just gave a getAdapter() and inserted the String into the returned Adapter. Then I gave a notifyChange...(). Success! Vlw to everyone!
– César Alves