我有一个困扰我的问题。我创建了一个字符串数组,strings.xml
其中称为bookmark_titles
. 我想将它用于我的警报对话框并使用它们填充一个列表,但是我看不到我的数组的名称R.array
,它只有那些内置在 android 中的,例如 PhoneTypes。如何引用我的数组?
strings.xml
<string name="app_name">Dialogs</string>
<string name="action_settings">Settings</string>
<string-array name="bookmark_titles">
<item>Google</item>
<item>Bing</item>
<item>Gmail</item>
</string-array>
</resources>
FireMissilesDialogFragment
public class FireMissilesDialogFragment extends DialogFragment{
public Dialog onCreateDialog(Bundle savedInstanceState) {
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setTitle("Books are :");
.setItems(R.array., new DialogInterface.OnClickListener() { ---> can't see reference here
public void onClick(DialogInterface dialog, int which) {
// The 'which' argument contains the index position
// of the selected item
}
});
return builder.create();
}