vendredi 3 janvier 2020

how to add dynamic checkbox inside web api response?

here is my code where I am getting my response in multiple timing slots I want to create multiple checkboxes according to time response here is my code :

  @Override
        public void onResponse(String response) {
            pd.dismiss();
            Log.e("@@TimeApi", response);
            try {

                JSONObject obj = new JSONObject(response);
                JSONObject objData = obj.getJSONObject("data");
                JSONArray jsonArray = objData.getJSONArray("time");

                AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());

                if (!obj.getBoolean("error")) {

                    for (int i=0; i<jsonArray.length(); i++){

                        String time = jsonArray.getString(i);
                        Log.e("@@Time", time);
                        final List<String> timeList = Arrays.asList(time);


                    }
                } else {
                    Toast.makeText(getActivity(), obj.getString("message"), Toast.LENGTH_SHORT).show();
                }

            } catch (JSONException e) {
                e.printStackTrace();
            }
        }

inside for loop, I am getting time now I need to put times in dialog with checkboxes

In the log I am getting a response like this time may come in multiple




Aucun commentaire:

Enregistrer un commentaire