2017년 6월 1일 목요일

HTML generation from Button Click event


I would like to generate a HTML file for my App I create using MIT App Inventor2.
I am looking at the code right now and wondering if I could call a HTML Generation function from the Event Listener of a button, would that work?
Where do I call my HTML Generation function in the code for that to happen?

Can anyone help? Thanks in advance?

--
You can read an html file with AI2 but you can not "generate" a html.  You can write and make the html (it is essentially a fancy text file) manually but this is not really practical inputting text with a phone or tablet on screen keypad..

--
Is it possible to replace source within the existing html with button click

--
I do not know Richard.   This post by Taifun seems to say he thinks it is possible to modify an existing html, however it does not provide any detail: Programmatically generating HTML using AI2 and presenting it via Webviewer  
I have not attempted this.  

Here are some things that I know can be done:

http://puravidaapps.com/table.php

table3.aia

http://puravidaapps.com/snippets.php#2webviewstring

webviewstring.aia

so if the html is structured correctly, you can post data and get a return.

Check it out, try some things and lets us know what you discover.

--
I would like to generate a HTML file for my App I create using MIT App Inventor2.
you can use the File component to store some text in a text file on sd card, and a html file is a text file, isn't it? Then you can use the webviewer to display that html file


alternatively you can pass html snippets via the webviewstring property to the webviewer, see here 


--


horizontal scrolling?


Isn't there an ability to scroll horizontally in AI2?
I looked around online and found this https://www.youtube.com/watch?v=iLgnrtIRv6o but I think that's a modified outdated version of AI, so I won't be using that.


but the video covers exactly what I'm trying to do, a horizontal layout of button which users can scroll through. Any thoughts?

--
This is not possible.
For the version in the video you have to pay 65 once and 5 per month.

--
But I really must find a way to make this work. Do you know of any alternatives method of displaying labels/buttons/anything horizontally without a limit?

--
OK, the best you can do with AI2 is Taifun's advice   
flung.aia
which probably is not sufficient for your purposes.  AI2 is an entry level Android compiler intended primarily for teaching programming.  If you need the features of a professional compiler, consider the free Eclipse and Android Studio Java based compilers.   You can horizontal scroll to your hearts content Lawrence with apps built with them.

--
If I may suggest something, You can create something like pages of buttons, instead of scrolling (which is not possible), just create a first set of buttons in a horizontal arrangement and add a small arrow button at the right end which makes the 1st set of buttons invisible and show the 2nd set. When you are showing the second set of buttons, add an arrow button on the left, to go back to the first set of buttons. I think it's the closest thing to what you need, doable in App Inventor.

--
Thanks for that link, it will suffice. 
Also I've previously used both eclipse and the android studio, and if I were to use android studio again, is there a way to transfer my current AI2 app to it?

--
No, there is no way to transfer.

--
The thought has crossed my mind, I appreciate the suggestion. 
I actually came up with a new idea similar to that, basically you can navigate through different screens by sliding left or right just like this example and just display the name of the page with a label at the very top of the screen.

BUT, there's a problem with that idea so I need an advice, the problem is the fact this example only works if you swipe on a canvas, but my app will display an array of buttons vertically. 
So my question is, how can I have an invisible canvas overlaying the whole screen? (because I only want to show the buttons while having the swiping work in order to access other screens)

--
This is getting interesting, lol. It's not possible to create a canvas on top of other elements, but maybe you can create a swiping area of maybe 50 pixels tall and all the way wide at the top or the bottom of the screen, you know what I mean?

--
how can I have an invisible canvas overlaying the whole screen?
this is not possible, but you could use sprites as alternative buttons

also probably my solution using a webviewer might be interesting for you
A powerful Label Alternative including touch gestures using the Webviewer, some HTML/jQuery and Hammer.js

--
Another idea: Use only the middle section while the sides are reserved for the buttons


--
Great thinking, I might follow that idea.
Thanks for all the replies guys, I gathered more intel than expected :)

--

need help for creating a sliding horizontal arrangement


hello everyone , i'm glad i'm texting you my questions , i would love to know how to use this app professionally cuz I've always loved programming and making software although i'm a civil engineering student . my question for now is about how can i make a horizontal arrangement slider which i can use my finger to slide left or right when i'm using the program . i mean it's just a flat screen , i wanna use sliding tools beside the switch which is already exist in the tool bar . and thank you all 

--
something like this is not available in App Inventor
but probably this example could be interesting for you

App Inventor JSON Parsing problem


Hello. I have a page with JSON code, for example: 
  "name": "numero_1", "value": 1782
},
{ "name": "numero_2", "value": 1348 
}, 
{ "name": "numero_3", "value": 578
I need to parse it to something like this: 
Numero_1: 1782
Numero_2: 1348
Numero_3: 578
The problem is, there are many "value" tags and when I try startTag "numero_2", "value": and endTag }, It's naturally now working. Is there a way to do this?

--
convert the json into a list of lists, then use the lookup in pairs block
see this example in the WebInfo.GotText event http://puravidaapps.com/oauth.php

--
Thanks, but it's pretty complicated. Isn't there an easier way?

--
actually using the JsonDecode block together with the lookup in pairs block makes it very simple...

--
I cannot see all of your JSON text so I had to do an example with my own.
--
Thanks for the answer. I feel a bit stupid now, but, I don't understand how does it work. So I will show you exactly I need. I upload a file which contains the data in the JSON file. It's from a game on Steam. I just want to take data from it, like "Kills: 213", "Deaths: 213", but the start tag is always "value". Thanks for your help.

JSON.txt

--
starting from what I said previously and the example from Scott should help you to understand how this works...
you might want to try something based on Scott's example and if you get stuck, post a screenshot of what have you tried

--
I don't understand how does it work.
What don't you understand?
As Taifun said, you should try using my example to parse your data file by trial and error if necessary, then come back for help if you still cannot get it to work.

--
I don't undrestand mainly the "list of lists". For what are the index numbers, and how is it all working..

Dňa nedeľa, 30. marca 2014 5:09:24 UTC+2 scottfromscott napísal(-a):


--
right click onto the blocks and select "Do it" to see the result of each step
1. the first step is to convert the json result into a list
2. then the first list item is selected of the list, which has been generated in step 1
3. then the second list item of step 2 is selected

--
So I somehow get it to work with this tutorial: http://www.appinventorblocks.com/appinventor-tutorials-tips/appinventor-web-component-json-response Thanks for help

--
I used this block to get a json response by index number or label. Hope it helps some one.

--
Thanks for sharing, Paul! I like the by index or label options :)

--

How to zoom the background image on the canvas ?


how to make pinch zoom on canvas without webviewer or html is it possible ?

--
There is no pinch event handler on a Canvas.    You could use a Touched or a TouchedDown or a TouchedUp or a Flung or a Dragged with some logic to replace the background image with a zoomed in or zoomed out version using IF then Else logic perhaps.

You can also zoom + or - the actual Canvas H and W.

--

i did a html image view it works and i try to add swipe between images but it doesn't work .these are the blocks can you check what wrong please
and this error shown "The operation - cannot accept the arguments: , [(file:///mnt/sdcard/AppInventor/assets/003.gif file:///mnt/sdcard/AppInventor/assets/004.gif)],"


--
the imageindex should be a number and not a filenname
remember you only can add or subtract numeric values, but no texts...

btw, how should that work in the webviewer? if you only display an image, then how can you receive some kind of event (for example swipe left or right)?
see here how to do it using the canvas https://puravidaapps.com/snippets.php#2flung
flung.aia

my label example https://puravidaapps.com/label.php uses HTML/jQuery and the Hammer.js library, which is able to detect touch gestures ...

--

search for hammer.js


my label example https://puravidaapps.com/label.php uses HTML/jQuery and the Hammer.js library, which is able to detect touch gestures ... Taifun.
... any number of rows and columns. A powerful Label Alternative including touch gestures using the Webviewer, some HTML/jQuery and Hammer.js ...
A powerful Label Alternative including touch gestures using the Webviewer, some HTML/jQuery and Hammer.js. Taifun.
... there is also the webviewer method. A powerful Label Alternative including touch gestures using the Webviewer, some HTML/jQuery and Hammer.js.
... gesture support, see here. A powerful Label Alternative including touch gestures using the Webviewer, some HTML/jQuery and Hammer.js. Taifun.
A powerful Label Alternative including touch gestures using the Webviewer, some HTML/jQuery and Hammer.js. Taifun.
... asset inside of App Inventor. A powerful Label Alternative including touch gestures using the Webviewer, some HTML/jQuery and Hammer.js Taifun.
no, but there is this workaround A powerful Label Alternative including touch gestures using the Webviewer, some HTML/jQuery and Hammer.js.
A powerful Label Alternative including touch gestures using the Webviewer, some HTML/jQuery and Hammer.js. Taifun.
... to the webviewer, for more see here A powerful Label Alternative including touch gestures using the Webviewer, some HTML/jQuery and Hammer.js.