I am trying to display a MaterialDialog that includes a list of strings.
The example code looks like this:
But I need to pass a dynamic string array to the routine instead of hard-coded strings in the above example code.
I tried creating a simple String array:
But I get a huge exception on the Builder.Show line that ends with:
The pop-up type description of the parameter says "Items (ItemArray() as CharSequence)"
So, I tried using the CSBuilder:
But I got this error during compile:
How can I pass a dynamic set of strings to the dialog's "Items" parameter?
I know it will probably end up being a simple solution, but I just hate all the time "syntax issues" like this waste with all the trial and error attempts I've made.
The example code looks like this:
B4X:
Builder.Title("Months and Days")
Builder.Items(Array As String("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"))
Builder.ItemsCallback
Builder.NegativeText("Cancel")
Builder.Show
But I need to pass a dynamic string array to the routine instead of hard-coded strings in the above example code.
I tried creating a simple String array:
B4X:
Dim D(3) as string
D(0) = "One"
D(1) = "Two"
D(2) = "Three"
...
Builder.Items(D)
B4X:
android.view.InflateException: Binary XML file line #1: Error inflating class <unknown>
at android.view.LayoutInflater.createView(LayoutInflater.java:640)
at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:55)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:689)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:748)
at android.view.LayoutInflater.inflate(LayoutInflater.java:483)
The pop-up type description of the parameter says "Items (ItemArray() as CharSequence)"
So, I tried using the CSBuilder:
B4X:
Dim cs As CSBuilder
cs.Initialize
cs.Append("one")
cs.Append("two")
cs.Append("three")
Builder.Items(cs)
But I got this error during compile:
B4X:
src\com\omnisoft\btgallery\directoryview.java:617: error: incompatible types: SpannableStringBuilder cannot be converted to CharSequence[]
_builder.Items((java.lang.CharSequence[])(_cs.getObject()));
How can I pass a dynamic set of strings to the dialog's "Items" parameter?
I know it will probably end up being a simple solution, but I just hate all the time "syntax issues" like this waste with all the trial and error attempts I've made.
Last edited: