'Positive button not showing up with MultiChoice AlertDialog
I have a multichoice alertdialog that's displaying a checklist of ~ 20 items, and 2 EditTexts, and positive button. It perfectly works when I display only ~ 8 out of the 20 items, but when I try to display the whole checklist, the 2 EditTexts and the positive button don't show up. Here's the method that creates the dialog.
fun newInterfacs(view: View) { //fait apparaître un pop-up qui permet d'entrer les différents paramètres pour créer une nouvelle interfacs
val equipes = arrayOf("ISEP", "CKO", "CP", "CdS", "AGRO", "Fronta", "CS", "CPSY", "CECS", "CELB", "Caré", "CéPHA", "CGéo", "CDH", "CD", "CM", "La Liégeoise", "CJC/CPL", "CPS", "CI", "CEBULB", "ACE")
val selectedList = ArrayList<Int>()
val builder = AlertDialog.Builder(this)
val inflater = layoutInflater
builder.setTitle("Nouvelles Interfacs")
builder.setMultiChoiceItems(equipes, null
) { dialog, which, isChecked ->
if (isChecked) {
selectedList.add(which)
} else if (selectedList.contains(which)) {
selectedList.remove(which)
}
}
val dialogLayout = inflater.inflate(R.layout.custom_view, null)
val sport = dialogLayout.findViewById<EditText>(R.id.sport)
val date = dialogLayout.findViewById<EditText>(R.id.date)
builder.setView(dialogLayout)
builder.setPositiveButton("OK") { _: DialogInterface, _: Int -> finish(view, sport, date, selectedList, equipes) }
builder.show()
}
And here's the custom_view layout
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<EditText
android:id="@+id/sport"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Entrez le sport"/>
<EditText
android:id="@+id/date"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Entrez la date"/>
</LinearLayout>
Is there anything I can do about it or the checklist is simply too long ?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
