I have found the following document at the Android dev site, which works for creating an AlertDialog with hard-coded elements : http://developer.android.com/guide/topics/ui/dialogs.html#AddingAList .
That works fine if you can hard-code them. However, in my application, I need to generate the items at runtime (prior to the generation, I don’t even know the length of the items list), when the Dialog is requested for the first time.
How can I use a list generated at runtime, instead of the final CharSequence[] used in the example for the items in the AlertDialog?
Thanks
Variable needs to be
finalonly if you access it from within an inner class (OnClickListener in this case). Do you need to access the item list within an inner class?finalonly means that reference must not change (= variable always points to same object). It says nothing how object is created. You can easily do: