I would like to know how you can modify an item x of a list view through the java code ...
I have the entry class object class:
public class Lista_entrada {
private String textoEncima;
private String textoDebajo;
private String texto_id;
public Lista_entrada(String textoEncima, String textoDebajo, String texto_id) {
this.textoEncima = textoEncima;
this.textoDebajo = textoDebajo;
this.texto_id = texto_id;
}
public String getTexto_id() {
return texto_id;
}
public String get_textoEncima() {
return textoEncima;
}
public String get_textoDebajo() {
return textoDebajo;
}
}
the adapter class
public abstract class Lista_adaptador extends BaseAdapter {
private ArrayList<?> entradas;
private int R_layout_IdView;
private Context contexto;
public Lista_adaptador(Context contexto, int R_layout_IdView, ArrayList<?> entradas) {
super();
this.contexto = contexto;
this.entradas = entradas;
this.R_layout_IdView = R_layout_IdView;
}
public Lista_adaptador( int entrada, ArrayList<Lista_entrada> datos) {
}
@Override
public View getView(int posicion, View view, ViewGroup pariente) {
if (view == null) {
LayoutInflater vi = (LayoutInflater) contexto.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
view = vi.inflate(R_layout_IdView, null);
}
onEntrada (entradas.get(posicion), view);
return view;
}
@Override
public int getCount() {
return entradas.size();
}
@Override
public Object getItem(int posicion) {
return entradas.get(posicion);
}
@Override
public long getItemId(int posicion) {
return posicion;
}
/** Devuelve cada una de las entradas con cada una de las vistas a la que debe de ser asociada
* @param entrada La entrada que será la asociada a la view. La entrada es del tipo del paquete/handler
* @param view View particular que contendrá los datos del paquete/handler
*/
public abstract void onEntrada (Object entrada, View view);
}
In my activity I fill the list and show it:
datos.add(new Lista_entrada("BUHO", "Búho es el nombre","textol bla bla"));
datos.add(new Lista_entrada("COLIBRÍ", "Los troquilinos","texto bla bla"));
lista = (ListView) findViewById(R.id.ListView_listado);
lista.setAdapter(new Lista_adaptador(this, R.layout.entrada, datos) {
@Override
public void onEntrada(Object entrada, View view) {
if (entrada != null) {
TextView texto_superior_entrada = (TextView) view.findViewById(R.id.textView_superior);
if (texto_superior_entrada != null)
texto_superior_entrada.setText(((Lista_entrada) entrada).get_textoEncima());
TextView texto_inferior_entrada = (TextView) view.findViewById(R.id.textView_inferior);
if (texto_inferior_entrada != null)
texto_inferior_entrada.setText(((Lista_entrada) entrada).get_textoDebajo());
TextView texto_id_entrada = (TextView) view.findViewById(R.id.textView_id);
if (texto_id_entrada != null)
texto_id_entrada.setText(((Lista_entrada) entrada).getTexto_id());
}
}
});
What I want to do is give a position of an item in the listview, modify it only to the, for example change the name of the item [0], Bhuo for Eagle, to give an example ....