1

I have a AlertDialog of Multichoice Items.I want to have an EditText beside each item. How do i achieve this?

 third_card.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                final AlertDialog.Builder mBuilder = new AlertDialog.Builder(EnterRecordActivity.this);
                mBuilder.setTitle("Select Contributor");
                mBuilder.setMultiChoiceItems(listMembers, checkedMembers, new DialogInterface.OnMultiChoiceClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int position, boolean isChecked) {

                    }
                });
                mDialog = mBuilder.create();
                mDialog.show();
            }
        });

This is what i achieved till now with the following code

this is what i achieved till now with the following code

this is what i want

This is what i want. An edit text with each multichoice item

Aniruddh Parihar
  • 3,072
  • 3
  • 21
  • 39

2 Answers2

1

Create custom dialog like this:

     AlertDialog.Builder builder = new AlertDialog.Builder(this);
            LayoutInflater inflater = (this).getLayoutInflater();
            //Your layout file name is custom_check_with_edt
            View dialogView = inflater.inflate(R.layout.custom_check_with_edt, null);
           //get Id from custom view            
            EditText edtNote = dialogView.findViewById(R.id.edt_notes);

            builder.setView(dialogView);
            builder.setPositiveButton("Ok", (dialog, which) -> {
                   //YOUR LOGIC
                }
                dialog.dismiss();
            });
            builder.setNegativeButton("Cancel", (dialog, which) -> dialog.dismiss());
            builder.setCancelable(true);
            Dialog dialog = builder.create();
            dialog.show();
Mitesh Vanaliya
  • 2,491
  • 24
  • 39
0

You can make your custom dialog by creating a class that extends the dialog class. Then you need to add the layout of the xml file. Follow this link How to create a Custom Dialog box in android? For multi choice and editext, use either listview or recycler view and define your item layout with checkboxes and edittext.

Saad
  • 28
  • 4