Page 1 of 1
Four options in Android dialog?
Posted: Mon Jan 08, 2018 8:21 pm
by yeldarb
So I'm building a mobile app, and I've made use of the ask/answer dialog, which provides a simple native solution. However, I have a couple questions that have four options, and I discovered that the native android dialog appears to be limited to three options. Is there any way around this limitation?
Re: Four options in Android dialog?
Posted: Mon Jan 08, 2018 10:13 pm
by quailcreek
Here's some code I use. It comes from a group that has a grc and a fld. It should get you started.
Code: Select all
put ("Nmae,Car,Date,Open,Closed,Top,Bottom") into pickList
replace comma with cr in pickList
put fld 1 of me into tCurrent
mobilePick pickList ,1,"Cancel"
put the result into ItemPicked
put line ItemPicked of pickList into theChoice
if ItemPicked is 0 OR (tCurrent = theChoice) then
exit to top
else
set the foregroundColor of fld 1 of me to 0,0,0
put line ItemPicked of pickList into fld 1 of me
end if
Re: Four options in Android dialog?
Posted: Tue Jan 09, 2018 1:10 pm
by MaxV
yeldarb wrote: ↑Mon Jan 08, 2018 8:21 pm
So I'm building a mobile app, and I've made use of the ask/answer dialog, which provides a simple native solution. However, I have a couple questions that have four options, and I discovered that the native android dialog appears to be limited to three options. Is there any way around this limitation?
No, with
mobilePick there is no limits See :
http://livecode.wikia.com/wiki/MobilePi ... Picker.png
Re: Four options in Android dialog?
Posted: Tue Jan 09, 2018 6:46 pm
by yeldarb
Ok, so I can use the mobile picker as a solution. I have two related questions:
1. How do I identify the choices in the mobilePicker? There doesn't seem to be an option for a label or title in any of the examples, though on the wikia page there's a label ("Ringtones").
2. How do I initialize a list and/or array so that I don't have to duplicate it for the native answer dialog? In other words, the mobilePicker takes a return-delimted string ("chioce1" & cr & "choice2") but the native answer dialog takes a string separated by " or " as in "chioce1" or "choice2". I haven't found a way to replace or split/combine with " or " so that I can use a previously defined string for the buttons in the answer dialog.
Re: Four options in Android dialog?
Posted: Wed Jan 10, 2018 4:52 pm
by MaxV
yeldarb wrote: ↑Tue Jan 09, 2018 6:46 pm
2. How do I initialize a list and/or array so that I don't have to duplicate it for the native answer dialog? In other words, the mobilePicker takes a return-delimted string ("chioce1" & cr & "choice2") but the native answer dialog takes a string separated by " or " as in "chioce1" or "choice2". I haven't found a way to replace or split/combine with " or " so that I can use a previously defined string for the buttons in the answer dialog.
Probably with the
do command and
replace you can do it.
Re: Four options in Android dialog?
Posted: Wed Jan 10, 2018 8:59 pm
by quailcreek
Hi yeldarb,
You have to understand that Android OS handles lists differently than does iSO. This is not a LC restriction but the limitations of the Android OS. The code I posted above is your best bet for accomplishing this task.
You can dynamically populate the variable "pickList" in the code I posted to accomplish this and you are correct, there is no option for a label. You could however, set the top item is the list as a label and then, in your code, handle what happens if that item is tapped by the user, ie exit to top.
1. How do I identify the choices in the mobilePicker? There doesn't seem to be an option for a label or title in any of the examples, though on the wikia page there's a label ("Ringtones").
Code: Select all
replace comma with " or " in pickList
2. How do I initialize a list and/or array so that I don't have to duplicate it for the native answer dialog? In other words, the mobilePicker takes a return-delimted string ("chioce1" & cr & "choice2") but the native answer dialog takes a string separated by " or " as in "chioce1" or "choice2". I haven't found a way to replace or split/combine with " or " so that I can use a previously defined string for the buttons in the answer dialog.