Listview with JSON + PHP

Asked

Viewed 151 times

0

I want you to appear in one ListView all the information of a select I gave. I can do only with txt by displaying information:

public void sendjsonrequest() {
    JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.GET, HOST, null, new Response.Listener<JSONObject>() {
        @Override
        public void onResponse(JSONObject response) {

            try {

                contrato = response.getString("contrato");
                tipo = response.getString("tipo");
                horario = response.getString("horario");


                //txtContrato.setText(contrato);
                //txtTipo.setText(tipo);
                //txtHorario.setText(horario);
            } catch (
                    JSONException e)

            {
                e.printStackTrace();

            }
        }

I’m wondering how to insert this information into a ListView.

contrato = response.getString("contrato");
tipo = response.getString("tipo");
horario = response.getString("horario");
  • 1

    Could clarify better where PHP comes into this story and what its relationship to the problem?

  • I connect Json with PHP where on the server there is a PHP file with SELECT. My doubt is how to take the String "contract, type and time" and put in a Listview to appear more than 1 die on the screen. I am currently using a Textview to show the result but only 1 appears.

  • the php tag makes no sense for that question

1 answer

0


To display these three data, create an object and fill it with this return of your php code.

public class MeuObjeto {
    private String Contrato, Tipo, Horario;
}

Next, create a list of these objects; use the concept of Recyclerview to create a listview with this data.

  • Thank you worked !

  • You can mark it as a response :)

Browser other questions tagged

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