Use of List String blocks in Sketchware android projects

A string list is an ordered collection of strings, where user has precise control over where in list each string is added. Use of list blocks in Sketchware projects is described below.

Adding elements to list

Elements can be add to a list one by one, and they take the position as per the sequence in which they are added.
For example, if we add Google, Yahoo, Amazon, YouTube, and Android to a list, they will take positions 0, 1, 2, 3, and 4 respectively.
If a very large number of elements are to be added to the list, as in some kind of word game, then multiple more blocks can be used to add elements to the list, and the more blocks can be used in a sequence in the event where list is to be created.
The images below show an example.



An important aspect of lists is that they allow duplicate elements and they allow multiple null elements.

Using List elements in Spinner or ListView

Elements added to a list can be shown in Spinner or ListView by setting their data to the list, as shown in the images below.
  a. Use of list in ListView

  b. Use of list in Spinner


Use of individual list blocks

1. Add...to List String...
This block is used to add elements to a list, as described above.

2. Inset...at...to List String...
This block can be used to insert an element at a particular position in between a list. If an element is inserted at position 3, the previous element at position 3 will shift to position 4, and all other elements at later positions will shift to one higher position.
The blocks used in the image above will give following result.
3. Delete at...of List...
This block can be used to delete an element from a particular position in list. All elements at higher positions will then shift down by one position.

4. Get at...of List String...
This block gets an element from a particular position in list.

5. Index...in list string...
This block gets the position of an element. For example, if Yahoo is at position 1, index Yahoo in List String will return result 1.

6. List String... contains...
This block checks if a particular string is there in the list.

7. Length of List...
This block gets the number of elements in the List. It counts from 1 to the last element. Thus, length of list is one higher than the last position in list.

8. Clear List...
This block deletes elements from all positions of the list.

Comments

  1. Thanks but
    How can I direct/define user selections of the spinner data

    ReplyDelete
  2. I need to move data from from fire base to client(no problem) then I need that added to a local list map ( I might be doing something wrong there) and finally I need that to customview data (on running code when data has been added I get error null object refrence) this is for a chat app so that time stamps are accurate for all users. I am having another issue withthe same area of the app one item of the list is an image which ive followed your totorial on converting to and from base64 and i can load it else where but in listview i get a transparent image. please post a reply or a tutorial thank you love your work.

    p.s. you should post an email just for help requests

    ReplyDelete
    Replies
    1. Ok ive made some progress on my issue i on data added i have the children to map list then to individual string lists then add x key x added to list localchat (like in the list of apps example) and then i set listview1 set custom view data to list localchat but only the text string is being displayed my other textviews are showing up blank

      Delete
  3. Hi, my crash-generated SketchWare application when I use more than two "get value of" to get data from Firebase. How to fix?

    ReplyDelete
  4. Hi please provide me the block program for select language button.

    ReplyDelete
  5. When i want IT to search An list
    The index operation wil crash
    Please help me

    ReplyDelete
  6. How to make expandable listview in sketchware

    ReplyDelete
  7. how to use insert key in a position of a listmap? i want to insert a key if the listmap doesnt contain that key. thanks.

    ReplyDelete
  8. How to insert key in a position of a listmap? I am using firebase database loaded to a custom listview. I want to insert data between position 2 and 3 in the custom listview. Please help.

    ReplyDelete
  9. Hii...is there any possibility to give values for the given lists in a spinner

    Ex: list football,crkicket,tennis

    Id i click football in spinner i get 20 points and 30 for cricket at last 25 for tennis...please help

    ReplyDelete
    Replies
    1. In spinner on item selected event, you can use this if..else....
      If position = 0,
      set points to (points +20)
      If position = 1,
      set points to (points +30)

      But reselection is not possible in this way. And when the page starts, the first item in spinner is automatically selected, so it will automatically add points for that.

      It will be better if you use a listview or dialog instead of spinner.

      Delete
  10. Is there any option to convert sketchware app to ios??

    ReplyDelete
  11. This comment has been removed by the author.

    ReplyDelete

Post a Comment

Popular posts from this blog

Simple car racing android game in Sketchware

Creating a Drawing View in Sketchware

Enable Fullscreen for Youtube videos in WebView

How to enable upload from webview in Sketchware?

List of Calendar Format symbols valid in Sketchware