getting error while doing multiplechecklist dialogue
java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.lang.Object.toString()' on a null object reference at android.widget.ArrayAdapter.createViewFromResource(ArrayAdapter.java:457) at android.widget.ArrayAdapter.getView(ArrayAdapter.java:419) at androidx.appcompat.app.AlertController$AlertParams$1.getView(AlertController.java:998) at android.widget.AbsListView.obtainView(AbsListView.java:2472) at android.widget.ListView.measureHeightOfChildren(ListView.java:1421) at android.widget.ListView.onMeasure(ListView.java:1327) at android.view.View.measure(View.java:24710) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6858) at android.widget.FrameLayout.onMeasure(FrameLayout.java:194) at android.view.View.measure(View.java:24710) at androidx.appcompat.widget.AlertDialogLayout.tryOnMeasure(AlertDialogLayout.java:134) at androidx.appcompat.widget.AlertDialogLayout.onMeasure(AlertDialogLayout.java:64) at android.view.View.measure(View.java:24710) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6858) at android.widget.FrameLayout.onMeasure(FrameLayout.java:194) at androidx.appcompat.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:143) at android.view.View.measure(View.java:24710) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6858) at android.widget.FrameLayout.onMeasure(FrameLayout.java:194) at android.view.View.measure(View.java:24710) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6858) at android.widget.FrameLayout.onMeasure(FrameLayout.java:194) at android.view.View.measure(View.java:24710) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6858) at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1552) at android.widget.LinearLayout.measureVertical(LinearLayout.java:842) at android.widget.LinearLayout.onMeasure(Li
try { mBuilder.setTitle("Select SubCategories"); mBuilder.setMultiChoiceItems(id, null, new DialogInterface.OnMultiChoiceClickListener() { @Override public void onClick(DialogInterface dialogInterface, int position, boolean isChecked) {
if (isChecked) {
if (!mUserItems.contains(id[position])) {
mUserItems.add(id[position]);
} else {
mUserItems.remove(id[position]);
}
}
}
});
mBuilder.setCancelable(false);
mBuilder.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int which) {
String item = "";
for (int i = 0; i < mUserItems.size(); i++) {
item = item + mUserItems.get(i);
if (i != mUserItems.size() - 1) {
item = item + ",";
}
// displaysub.append(item[i]);
}
displaysub.setText(item);
}
});
mBuilder.setNegativeButton("Dismiss", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
dialogInterface.dismiss();
}
});
mBuilder.setNeutralButton("Clear All", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int which) {
for (int i = 0; i < checkedItems.length; i++) {
// checkedItems[i] = false;
mUserItems.clear();
// mItemSelected.setText("");
displaysub.setText("");
}
}
});
AlertDialog mDialog = mBuilder.create();
mDialog.show();
}catch (Exception ex){
ex.printStackTrace();
}
Aucun commentaire:
Enregistrer un commentaire