I create my AlertDialog on Android with the content I need:
new AlertDialog.Builder(this) .setTitle(...) .setView(R.layout.layout_settings) // вот моя Layout .setPositiveButton("ok", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface i1, int i3) { ... return; } }) .setNegativeButton("cancel", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface i1, int i3) { ... return; } }) .create() .show(); In this my Layout R.layout.layout_settings there is a ListView :
<ListView android:id="@+id/myListView" android:layout_width="match_parent" android:layout_height="wrap_content" /> How to add a String[] array with values to it? Here without all these R.layout.simple_list_item_1 as written here . Does not work! An exception is thrown:
java.lang.NullPointerException:
Attempt to invoke virtual method 'void android.widget.ListView.setAdapter (android.widget.ListAdapter)' on a null object reference
I need to simply and elementarily point my ListView an ordinary String[] array. With these I will not express "simple_list_item .." easier to shoot.
I am not going to create any additional XML files (for example, Layout) for some unimportant ListView . Need another option.
myListView.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, new String[]{...});Sorry, forgot to specify it in the question. - nickmyListView- Nikotin N