0
I have the following code that should return a data list
package com.example.gustavo.domanda;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import com.android.volley.RequestQueue;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.Volley;
import java.util.ArrayList;
public class ConsultarActivity extends AppCompatActivity {
private ListView lvReservas;
private int idusuario;
private String nome;
private String sobrenome;
private RequestQueue mVolleyRequest;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_consultar);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
Bundle extra = getIntent().getExtras();
if(extra != null){
idusuario = extra.getInt("idusuario");
nome = extra.getString("nome");
sobrenome = extra.getString("sobrenome");
}
getAgenda(idusuario);
}
private void getAgenda(int idusuario) {
int opcao = 3; //mostrar agenda do cliente
final ArrayList<ConsultarPojo> agendaCliente = new ArrayList<>();
RequestQueue queue = Volley.newRequestQueue(this);
GsonRequest<ConsultarPojo[]> request = new GsonRequest<>("http://reservacomdomanda.com/areaAdmin/api/admin_estabelecimento/reqScheduleProJson.php?" +
"idcliente="+idusuario+"&opcao="+opcao, ConsultarPojo[].class, null, new Response.Listener<ConsultarPojo[]>() {
@Override
public void onResponse(ConsultarPojo[] response) {
Log.d("TAG", "Retorno... " + response);
for (int i = 0; i < response.length; i++) {
ConsultarPojo agc = new ConsultarPojo();
agc.dia = response[i].dia;
agc.hora = response[i].hora;
agendaCliente.add(agc);
}
ArrayAdapter<ConsultarPojo> adapter = new ArrayAdapter<ConsultarPojo>(ConsultarActivity.this, android.R.layout.simple_list_item_1, agendaCliente);
lvReservas = ((ListView)findViewById(R.id.lvReservas));
lvReservas.setAdapter(adapter);
adapter.notifyDataSetChanged();
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Log.d("Error.Response", String.valueOf(error));
}
});
queue.add(request);
}
}
And on the line where I wrote "TAG", "Return... " + Sponse, on the console appears
D/TAG: Return... [Lcom.example.Gustavo.domanda.Consultarpojo;@f6cde00
What mistake or problem is this?
And what should I do to show the data of the object? I already put Sponse.toString() but it did not help
– GustavoSevero
@Gustavosevero, you asked a question and it was answered. If that’s not what you wanted to ask, ask another question.
– ramaral
"TAG", "Retorno... " + responseis equal to"TAG", "Retorno... " + response.toString()– ramaral
Putting Sponse.toString() did not help, unfortunately
– GustavoSevero
I didn’t tell you to put
response.toString(). On the contrary, you said it was the same. You asked, in relation to what appeared in the log, "What mistake or problem is this?" that’s what I answered to.– ramaral
All right, thanks for your help.
– GustavoSevero