Posts

Showing posts from June, 2018

JSON syntax

Image
JSON syntax rules

Data is in name/value pairs
"My name":"Sanjeev"

Data is separated by commas
{
"name" : "Sanjeev",
"age" : "29",
"registration number" : "1628634"
}

Curly braces hold objects
{
"name" : "Sanjeev",
"age" : "29",
"registration number" : "1628634"
}

Square brackets hold arrays
[
{
"name" : "Sanjeev",
"age" : "29"
},
{
"name" : "Ranju",
"age" : "25"
},
{
"name" : "Anand",
"age" : "16"
},
{
"name" : "Richa",
"age" : "20"
}
]A name/value pair consists of
a fieldname or key(in double quotes),
followed by acolon,
followed by avalue.

{"name":"Sanjeev"}
Types of Values in JSON

In JSON,valuesmust be one of
the following data types:

a string (Strings in JSON must be written in double quotes) {
"age&quo…

Loading images in WebView in Sketchware

Image
We can use WebView for loading images from any url or for loading images from drawable folder, assets folder, or resource folder of our app.

1. To load an image from a website in WebView, we can directly write the url of the image in the WebView loadUrl block. Even animated gifs can be loaded directly to WebView.

WebViewwebview1loadUrlhttp://.....jpg

2. We can modify the width and height of this image loaded in WebView by using following code in WebView loadUrl block:

WebViewwebview1loadUrldata:text/html,<img width=100% height="" src="(imageUrl)">
We can make it fit the width of the screen by setting width=100% in above code.

3. We can also load the images added using Image Manager in Sketchware (images in drawable folder) with following code:

WebViewwebview1loadUrlfile:///android_res/drawable/image
Note that in above code image is name of the image and has to be changed accordingly. Note that animations do not work with this method.
4. Another way to load an i…