1
我有一個簡單的警告對話框,如下所示,使用簡單的字符串數組(a)。我想用更復雜的字符串數組(b)替換(a),但當對話框嘗試解析視圖時,我得到空指針異常。使用複雜的字符串數組資源設置AlertDialog
這是可能的或我做錯了什麼?
的(a)
AlertDialog Code:
final AlertDialog.Builder dialog = new AlertDialog.Builder(new ContextThemeWrapper(ctx, R.style.mytheme));
dialog.setTitle(title);
dialog.setIcon(R.drawable.ic_launcher);
dialog.setSingleChoiceItems(R.array.array_items, -1, itemSelectedListener);
final AlertDialog alertDialog = dialog.create();
array_items.xml:
<string-array name="array_items">
<item>option a</item>
<item>option b</item>
</string-array>
(B)
array_items_2.xml:
<string-array name="array_items_2">
<item>@array/array_items.xml</item>
<item>@array/array_items.xml</item>
</string-array>
第二個XML將導致AlertDialog與一個NullPointerException崩潰。
我犯了一個錯誤,或者這是不可能的AlertDialog沒有自定義視圖?