$Questions = (Questions::all()); $arr = array(); foreach ($Questions as $Question){ $arr[] = $Question ; } return $arr ;
public void getMainQuestions(final OnRecievedMainQuestion onRecievedMainQuestion) { JsonArrayRequest request = new JsonArrayRequest(Request.Method.GET, "http://192.168.1.4:8000/api/mainQuestion", null, new Response.Listener<JSONArray>() { @Override public void onResponse(JSONArray response) { Question question = new Question(); ArrayList<Question> questions = new ArrayList<>(); for (int i = 0; i < response.length(); i++) { try { question.setId(response.getJSONObject(i).getInt("id")); question.setTitle(response.getJSONObject(i).getString("title")); question.setContent(response.getJSONObject(i).getString("content")); questions.add(question); } catch (JSONException e) { e.printStackTrace(); } } onRecievedMainQuestion.Recivied(questions); } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { } }); request.setRetryPolicy(new DefaultRetryPolicy(18000, DefaultRetryPolicy.DEFAULT_MAX_RETRIES, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT)); Volley.newRequestQueue(context).add(request); }
onResponse()
response.length()
for()
questions
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)