Problems setting an Adapter on the list

Asked

Viewed 33 times

0

I need to create a dynamic list, I do not understand well how it does, some people told me that it is made with adapter and so I’m trying to do.

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

First mind I call a function with success of the JSON response, and as I said, in it I’m sure it’s being done in the right way, 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 functionconfigurarAdapter() I do so:

 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 at the first line after the private void

I had to implement the class onGetView but I didn’t add anything inside her:

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

}

1 answer

0


After trying many times, I succeeded, they were a set of things that needed to be done:

1st did not set my view in mine onCreate

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

2º I altered the parameter I’m passing, I did so:

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

With this I solved my problem.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.