1
I made a method for when I click on a listview item it change color.
The problem is that it also changes color all items that have a range of 12 items of the item I clicked.
For example:
I have a listview with numbers from 1 to 30, if I click on the number 1 it will turn green, however the 13 also 25 will also.
I saw that this is a listview problem but someone has had some similar problem and knows how to solve?
Code I’m using:
@Override
public void onItemClick(AdapterView<?> parent, View view, int position,
long id) {
String stringNomeProduto = adapter.getItem(position);
Intent i = new Intent(this, Formulario.class);
i.putExtra("stringNomePais", stringNomePais);
i.putExtra("stringIdContinente", getIdContinente);
startActivityForResult(i, 0);
//muda de cor o produto que já foi preenchido
System.out.println("resultado 2: " + resultado);
if (adapter.getItem(position).equals(resultado)) {
View v = adapter.getView(position, view, parent);
v.setBackgroundColor(Color.LTGRAY);
}
adapter.getItem(position);
}
Where is the color change being made? Post this code.
– ramaral
my code is as simple as possible, I think it won’t help at all, posted an image showing how listview works, is this problem I’m having.
– daniel12345smith