あなたは配列リストと整数配列を使用することができます
List<Integer> myin=new ArrayList<>(); //you can add to this dynamically
myin.add(1); //adding values
myin.add(2);
Integer [] selected = myin.toArray(new Integer[myin.size()]); //converting to array
のArrayList:あなたのInteger[]
としてInitilize
Integer[] selsected;
selected = new Integer[] {1,2};
new MaterialDialog.Builder(this).title(R.string.socialNetworks)
.items(socialNetworks)
.itemsCallbackMultiChoice(selected, (dialog, which, text) -> {
StringBuilder str = new StringBuilder();
for (int i = 0; i < which.length; i++) {
if (i > 0) str.append('\n');
str.append(which[i]);
str.append(": ");
str.append(text[i]);
}
showToast(str.toString());
return true; // allow selection
})
.onNeutral((dialog, which) -> dialog.clearSelectedIndices())
.onPositive((dialog, which) -> dialog.dismiss())
.alwaysCallMultiChoiceCallback()
.positiveText(R.string.md_choose_label)
.autoDismiss(false)
.neutralText(R.string.clear_selection)
.show();