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 want. An edit text with each multichoice item
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();
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.