ListView is not displayed correctly when swiping

1

I have a generic abstract class that inherits from BaseAdapter and which I use to load ListView (s) from a ArrayList of any objects. The class works well and being abstract forces me to implement the onEntrada method that is the one I use for each object and the new view that is filled in, that is, the mold layout to be filled in.

So far, the problem is that when I slide my finger on the tablet that I have for the tests the letters of the TextViews if they overwrite seeing the fatal thing, until I loose and return everything to its place.

I thought the problem came because the ListView calls the getView function continuously and reloads all the data, so I tried something I found around here, to create a static ViewHolder class with the Views equal to the ones I need per row and go checking that it has not been filled, but the result is the same. You see the fatal thing. I do not know if it's a problem with the Android version, the size of the Tablet, the performance (the latter misses me, it's a Samsung Galaxy of the last and it's going very well). If someone has happened or better know the solution to see if you can throw a cable. I leave the class I use as Adpater.

public abstract class Lista_adaptador extends BaseAdapter {

    private ArrayList<?> entradas;
    private int R_layout_IdView;

    public Context getContexto() {
        return contexto;
    }

    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;
    }

    @Override
    public View getView(int posicion, View view, ViewGroup pariente)
    {View v = view;
        if (v == null) {
            LayoutInflater vi = LayoutInflater.from(contexto);
            v = vi.inflate(R_layout_IdView, null);
        }
        else
        {

        }
        onEntrada(entradas.get(posicion), v);
        return v;

    }

    @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);

}

Thanks Einer probe v = vi.inflate (R_layout_IdView, relative, false); and the thing remains the same. I attached an image of how it looks.

The class is abstract as I say you can use any other class to load your ListView, just have an ArrayList of any objects and implement the OnEntry () Example:

Aggregated list.setAdapter (new Adapter_list (this, R.layout.linea_note, Aggregated data) {

        @Override
        public void onEntrada(Object entrada, View view) {
             //Aquí se rellenan los views de la view de entrada.
         }

One of the xml I use to inflate the cells in the lists is this:

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_weight="1"
    android:orientation="vertical">

    <TextView
        android:id="@+id/tv_refLineaNota"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="Referencia"
        android:textSize="18sp" />

    <TextView
        android:id="@+id/tv_nombreLineaNota"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="Nombre de Linea de Nota"
        android:textSize="18sp" />

</LinearLayout>

<TextView
    android:id="@+id/tv_cantidadlineanota"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:layout_weight="0"
    android:gravity="center"
    android:paddingRight="5dp"
    android:text="Cantidad"
    android:textSize="18sp" />

<TextView
    android:id="@+id/tv_tipounidadLineaNota"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:layout_gravity="right"
    android:layout_weight="0"
    android:gravity="left|center"
    android:paddingRight="5dp"
    android:paddingTop="2dp"
    android:text="Kg" />

    
asked by Miguel Gijon 20.09.2017 в 15:02
source

1 answer

0

The error seems pretty weird, and without the code to debug I'll have to make a couple assumptions. The first thing is that I find it a little strange how you implement the adapter, letting an external class implement the method onEntrada and that it is the latter that inflates the list. Maybe it is because of this that this strange effect is generated, since while the adapter controls the scrolling of the list, it is another activity that is inflating as the elements of the list are scrolled. I recommend that you change the way you implement the adapter to a more standard way. I do not understand the operation of onEntrada very well, but when you do not see that you modify the view in "getView ()" I suppose you do it in "onEntrada () "

    
answered by 21.09.2017 в 17:09