looping a button

61 views
Skip to first unread message

agnes van

unread,
Apr 5, 2019, 3:34:48 AM4/5/19
to MIT App Inventor Forum
Hello guys,

i have a problem about using button. I've got parsed data from json. and then, every group data i want insert a button. but i dont know how to make it. i've tried using adding item(button) to list, but i got an error message. anybody help me to fix it?


thanks a bunch guys..

Ghica

unread,
Apr 5, 2019, 4:32:50 AM4/5/19
to MIT App Inventor Forum
Hi Agnes,
I am not a guy, and probably you are not a guy either, so be polite!
Anyway, if you want help, you could post the blocks you tried, the error message you received, etc.

And, it is not possible to create buttons dynamically. You can make buttons visible/ invisible etc., or there are several options:
1. Create as many buttons as you think you need (remember that you can only see a limited amount of them on your screen). make them visible as required and reuse buttons.
2. Use a canvas with sprites which have a button shape. You still need to create the sprites in advance.
which may or may not work in AI2 from MIT.

Cheers, Ghica.

TimAI2

unread,
Apr 5, 2019, 5:40:15 AM4/5/19
to MIT App Inventor Forum
Sounds like you want to create a list from your parsed data, then use a listpicker, listview or spinner to access all the items....

ABG

unread,
Apr 5, 2019, 10:39:48 AM4/5/19
to MIT App Inventor Forum

Ghica

unread,
Apr 6, 2019, 10:13:47 AM4/6/19
to MIT App Inventor Forum
Sorry Agnes, you sent a reply to me personally, and since others may be able to help too, I do not reply to these.
To speed things up: it is hard to read your blocks, therefor make a better picture in this way:
Press with your right mouse button in an empty space in the blocks editor, choose download blocks as image and post your downloaded image.
Maybe also post an .aia and an example of the JSON you receive.
Cheers, Ghica

TimAI2

unread,
Apr 7, 2019, 5:03:34 AM4/7/19
to MIT App Inventor Forum
Please share your parsed json data, or an example of it, and an image of your blocks here, then we can help a bit more....

agnes van

unread,
Apr 7, 2019, 10:12:20 PM4/7/19
to MIT App Inventor Forum
Hello,

Thankyou for your advice Tim Carter, Ghica, and TimAI2, here i send example of parsed JSON that i've been made and the code blocks. I hope there is a way out to solved this problem.


Thankyou for your helps..

parsed JSON agnes.jpg

Agnes

blocks(1).png


Ghica

unread,
Apr 8, 2019, 7:12:09 AM4/8/19
to MIT App Inventor Forum
Hi Agnes,
Your output is not what we asked for. We would like to see your raw json data.
Do this:
  • Define a global variable: rawJson
  • insert as first line in WebBuku.GotText: set global rawJson to get responseContent
  • execute your webquery
  • drag a block get global rawJson to some empty space in your block editor
  • click with your right mouse button on the get global rawJson block
  • choose DoIt from the pop-up menu
  • You should see a comment appearing which contains the raw json you received.
  • click on the comment block and enter Ctrl-A, this should select all text in the comment block.
  • now enter Ctrl-C, you have now all the text of the json that you could past in your post, or, if it is very long, past it into a text file that you could create and post the text file.
This said, there are some strange things in your blocks.
  1. You are using PostText and Get right after each other, maybe you will also get 2 when WebBuku.GotText events. I think it should be one or the other but not both.
  2. In when WebBuk.GotText you set global test two times immediately after each other, so only the second set of global test will remain, but what it is for is not clear, you get a list of two elements where the json is split at the first space??
  3. you have in the getAllData proced
  4. Probably your error message is caused by this very strange block:
    Snap31.png
    You make a list of one element that contains an instance of the ButtonOnLoc component. You then use this in your join. But join only joins text and the strange text you see in your output is the result of an internal routine trying to make text of your button. You *cannot* insert real buttons in this way. In App Inventor there is actually no way you could get a dynamic button in your text. What was it that you would like to do here??
  5. There are much better ways to parse a json result, but if it works, it works. If you would like more help with this, post a json example as explained above.
Cheers, Ghica.

ABG

unread,
Apr 8, 2019, 10:13:49 AM4/8/19
to MIT App Inventor Forum
See this site for what we mean by samples of JSON data ...


ABG

Reply all
Reply to author
Forward
0 new messages