3
I add the values that are within 3 arrays
in the hashMap
to insert into the listview
:
ArrayList<HashMap<String, String>> lista = new ArrayList<HashMap<String,String>>();
for(int i=0; i<tema.length; i++ ) {
HashMap<String,String> item = new HashMap<String,String>();
item.put("tema", tema[i]+": "+tempo[i]);
item.put("palavras", palavras[i]);
lista.add(item);
}
What I want to do is that when the user clicks the button SUBIR
, for example. The item in position 2 (if that’s what he clicked on) rises to position 1, and the item in position 1 takes position 2.
Replacing:
up.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if(posicao!=0 && tema.length>1) {
auxtema = tema[posicao-1];
auxpalavras = palavras[posicao-1];
auxtempo = tempo[posicao-1];
tema[posicao-1] = tema[posicao];
palavras[posicao-1] = palavras[posicao];
tempo[posicao-1] = tempo[posicao];
tema[posicao] = auxtema;
palavras[posicao] = auxpalavras;
tempo[posicao] = auxtempo;
}
Inside the array I was able to do. I replaced it, but how do I update it inside the listview, and update it?
I don’t have enough data on your code/Adapter to give you a specific solution, but remove the item of
ArrayList
and callnotifyDataSetChanged
should work. Take a look in that SOE response.– Anthony Accioly