Four options in Android dialog?

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
yeldarb
Posts: 43
Joined: Thu Dec 14, 2017 5:39 pm

Four options in Android dialog?

Post by yeldarb » 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?

quailcreek
Posts: 746
Joined: Sun Feb 04, 2007 11:01 pm
Location: McKenna, WA

Re: Four options in Android dialog?

Post by quailcreek » Mon Jan 08, 2018 10:13 pm

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
Tom
MacBook Pro OS Mojave 10.14

MaxV
Posts: 1579
Joined: Tue May 28, 2013 2:20 pm
Location: Italy
Contact:

Re: Four options in Android dialog?

Post by MaxV » Tue Jan 09, 2018 1:10 pm

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
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w

yeldarb
Posts: 43
Joined: Thu Dec 14, 2017 5:39 pm

Re: Four options in Android dialog?

Post by yeldarb » Tue Jan 09, 2018 6:46 pm

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.

MaxV
Posts: 1579
Joined: Tue May 28, 2013 2:20 pm
Location: Italy
Contact:

Re: Four options in Android dialog?

Post by MaxV » Wed Jan 10, 2018 4:52 pm

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.
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w

quailcreek
Posts: 746
Joined: Sun Feb 04, 2007 11:01 pm
Location: McKenna, WA

Re: Four options in Android dialog?

Post by quailcreek » Wed Jan 10, 2018 8:59 pm

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.
Tom
MacBook Pro OS Mojave 10.14

Post Reply

Return to “Getting Started with LiveCode - Experienced Developers”