Problems setting up an adapter in the list

0

I need to create a dynamic list, I do not quite understand how it does, some people told me it's done with adapter and so I'm trying to do it.

According to break point my data is arriving perfectly, and all of it is being set correctly in my Entity.

First I call a successful function of the JSON response, and as I said, in it I'm sure it's done correctly, I programmed it as follows:

private void sucessoResposta(String json) {
   Comentarios comentariosRetorno = null;
   try {
        comentariosRetorno = JSONParser.parseComentarios(json);
        lstComentarios = comentariosRetorno.getComentarios();
        configurarAdapter();
    } catch (Exception e) {
        MessageUtil.showError(getApplication(), R.string.erro_desconhecido);
    }
}

In function configurarAdapter() I do this:

 private void configurarAdapter() {
    adapter = new GenericAdapter<>(getParent(), lstComentarios,R.layout.item_comentario);
    adapter.setOnGetViewEvent(this);
    lisComentarios.setAdapter(adapter);
    lisComentarios.setEmptyView(lytEmptyComentarios);
}

When I am debugando the code it stops on the first line after private void

I had to implement the class onGetView but within it I did not add anything inside it like this:

@Override
public void onGetView(Comentarios item, View view, boolean isNewView, int position) {

}
    
asked by anonymous 24.05.2017 / 15:04

1 answer

0

After trying many times, I was successful, it was a set of things that needed to be done:

I have not set my view in my onCreate

lisComentarios = (ListView) findViewById(R.id.lisComentarios);
lytEmptyComentarios = (LinearLayout) findViewById(R.id.lytEmptyComentarios);

2º I changed the parameter I'm going through, I did so:

adapter = new GenericAdapter<>(this,lstComentarios,R.layout.item_comentario);

With this I solved my problem.

    
24.05.2017 / 21:37