I add values that are within 3 arrays
in hashMap
to insert in 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 when the user clicks the SUBIR
button, for example. The item that is in position 2 (if it has been clicked) goes up to position 1, and that which was in position 1 occupies 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 could do. I replace, but how do I update this within the listView , and update it?