Tired of making long lists (or even short lists) with LOTS of blocks? Try this instead:
The very simple way using AI2 Blocks and hard-coding the List elements:
Construct a List called MyList from a csv text file created within and hard coded into an app. The list is: 0.1,0.4,0.3,0.2,one,four,three,two . Type it in the maroon block or type it in Notepad or another text editor and drag and drop it from Notepad into the empty maroon Text block. The easiest and safest way to create a long List is to use a text editor to create the list using drag and drop to populate the Text block (you really do not want to type all those blocks do you?). If you need to change the list or an element of the list, change the text in your Notepad file and replace what is in the Text block with that. Yes, use the list from csv row text block to make the text a List.
Another way to create the List is to use the File component to populate MyList on loading the app. This way is more complicated. Create a file called MyList.csv with Notepad. Put it in a directory on your Android device using a file manager or by using your Android as a memory device hooked by USB to your PC. You can then read the file using call File1.ReadFrom
fileName where what you put there is the location of MyList.csv . If you put the file in the Media (yes, you can load the text csv file into Media just like a photo or sound bite), this is easy ..no need for a File editor and name use the fileName MyFile.csv
Put the File1.ReadFrom block in the app's Screen1.Initalize method handler, then use the When File1.GotText do block event handler to set global MyList to text . Your MyList global now has the contents of the Notepad list.
--
DOH!!! DOH!! DOH!!
LOL. The above is from my second app. When I created that bit I forgot one of my own rules about computers: "If it seems like a pain in the ... there's probably another way!"
Thank you Steve! :) You're technique would also work with list from csv table to create a list of lists like I needed.
--
list from csv table 0.1,0.4,0.3,0.2 /n one,four,three,two using the example list above possibly?
--
Hi, If one or more elements contains comma? How is possible to use list from csv row in this case?
--
@Francesco I think you can handle that by putting internal commas within quote marks, but I am not sure. "," ... try it and tell us what happens. You may have to put the entire list item within quotes. Try that too.
--
댓글 없음:
댓글 쓰기