I would like to implement a Custom Multiple Choice Dialog
, so following the directions from this answer, this is what I did:
I created the xml
for my row, which is a CheckedTextView
<CheckedTextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/text1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceListItemSmall"
android:gravity="center_vertical"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:textColor="#000000"
android:fontFamily="sans-serif-condensed"
style="?android:textAppearanceSmall"
android:background="?android:attr/activatedBackgroundIndicator"
android:minHeight="?android:attr/listPreferredItemHeightSmall"
android:checkMark="?android:attr/listChoiceIndicatorMultiple"
android:clickable="true"/>
Now, my Dialog
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setAdapter(
new ArrayAdapter<String>(getActivity(),
R.layout.dialog_list_item, tables), null)
// Set the action buttons
.setPositiveButton(android.R.string.ok,
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {
dialog.dismiss();
}
});
AlertDialog alertDialog = builder.create();
alerDialog.show();
As you can see, I have not implemented an setOnItemClickListener
yet, but I do not know how though. However, the Dialog
looks fine. How can I call a ClickListener for each of the CheckedTextView
?
Than you very much