How to loop multiple textview and send it to single textview when clicked

Viewed 37

I am trying to achieve following thing.

  1. I added an alert dialog which shows following image: alertbox image
  2. When the user presses the first option it should send it to another textview hidden in this
  3. I have four options and each one needs to be executed when the user clicks it. Like if the first one buffer is clicked that should be sent to an edittextview and saved there like buffer.settext(edittextview). This can be done in a single task but I want that to be in loop.

Here is my code snippet for reference:

LinearLayout reportButtonLinearLayout= findViewById(R.id.reportButton);
reportButtonLinearLayout.setOnClickListener(view -> {
    if(userData != null) {
        final Dialog dialog = new Dialog(MovieDetails.this);
        dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
        dialog.setCancelable(false);
        dialog.setContentView(R.layout.reportapp);
        dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
        dialog.setCanceledOnTouchOutside(true);

        ImageView dialogClose = (ImageView) dialog.findViewById(R.id.Coupan_Dialog_Close);
        dialogClose.setOnClickListener(v -> dialog.dismiss());

        EditText titleEditText = dialog.findViewById(R.id.titleEditText);
        titleEditText.setText(name);
        TextView buffering = dialog.findViewById(R.id.buffering);
        TextView descriptionEditText = dialog.findViewById(R.id.descriptionEditText);

        buffering.setOnClickListener(btnView -> {
            RequestQueue queue = Volley.newRequestQueue(this);
            StringRequest sr = new StringRequest(Request.Method.POST, AppConfig.url + "createReport", response -> {
                if (helperUtils.isInt(response)) {
                    dialog.dismiss();
                    Snackbar snackbar = Snackbar.make(rootView, "Report Successfully Submited!", Snackbar.LENGTH_SHORT);
                    snackbar.setAction("Close", v -> snackbar.dismiss());
                    snackbar.show();
                } else {
                    dialog.dismiss();
                    Snackbar snackbar = Snackbar.make(rootView, "Error: Something went Wrong!", Snackbar.LENGTH_SHORT);
                    snackbar.setAction("Close", v -> snackbar.dismiss());
                    snackbar.show();
                }
            }, error -> {
                // Do nothing because There is No Error if error It will return 0
            }) {
                @Override
                protected Map<String, String> getParams() {
                    Map<String, String> params = new HashMap<>();
                    params.put("user_id", String.valueOf(userId));
                    params.put("title", descriptionEditText.getText().toString());
                    params.put("description", final_text);
                    params.put("report_type", String.valueOf(1));
                    return params;
                }

                @Override
                public Map<String, String> getHeaders() throws AuthFailureError {
                    Map<String, String> params = new HashMap<>();
                    params.put("x-api-key", AppConfig.apiKey);
                    return params;
                }
            };
            queue.add(sr);
        });
        dialog.show();
    } else {
        Snackbar snackbar = Snackbar.make(rootView, "Login to Report Content!", Snackbar.LENGTH_SHORT);
        snackbar.setAction("Login", v -> {
            Intent lsIntent = new Intent(MovieDetails.this, LoginSignup.class);
            startActivity(lsIntent);
        });
        snackbar.show();
    }
  });
}
0 Answers
Related