2
Assuming I have an object called Item, and it has the text, id and validation property, in which case, text is a string, id is an integer, and validation is a boolean value.
class Item
{
private int id;
private String texto;
private boolean validacao;
//get and set
}
And may this object serve as a parameter for an Arrayadapter
ArrayAdapter<Item> itemAdapter = new ArrayAdapter<Item(this,R.layout.layoutItem,view)
//no momento os parametros do construtor do ArrayAdapter não são levados em conta
But I need to be able to customize some elements of each Listview line according to the items.
Each line will have:
1- an image, which will be chosen according to the value of the validation attribute of the current line item.
2-an Edittext, which will receive and manipulate the value of the text property of the current line Item.
4-an image with a trash bin design that when clicked deletes the current item.
5- The item id should be changed according to the position in the array.
How can I customize view lines this way? , should I create a class that extends the Arrayadapter class ? , have a few examples ? or an alternative, or standard, better for this need ?
That’s right Leonardo, you’ll have to extend the class
ArrayAdapter
. Here is an example of a question I answered, which may help you get started: http://answall.com/questions/26229/como-mudar-a-cor-do-texto-de-um-listview/26231#26231. In case you can change elements of a row, addListeners
.– Wakim
would that be the right way ? http://www.ezzylearning.com/tutorial/customizing-android-listview-items-with-custom-arrayadapter
– leonardo freitas oliveira
but there is still a doubt , the events of an element within a list will respond normally as for example , on click
– leonardo freitas oliveira
Exactly, my example was only to paint the color of the text, but it is possible to do much more. Yes, they will respond normally by simply adding the Istener. For this I suggest (it is not obligatory) to use this way that I did in the answer to this question: http://answall.com/questions/32771/problems-ao-dataos-de-um-listview-para-activity/32885#32885. Using the
Adapter
like theOnClickListener
you avoid creating so manyListeners
as many as your itemsListView
, best for GC.– Wakim