List are essential for structuring a mobile app. We already explained how to create a list online and change it in real time through mvsappmobile.com portal. This is a very simple way for keeping up-to-date data displayed in your app.
If the information to be displayed comes from a structured data source, you should consider exporting this data regularly to a file, put this file online and configure its URL once for all in AppMobile. For future exports, you will just have to replace the file online by the new export, and the updated data will be immediately available in you mobile apps.
Much better, if you data is stored in an online database, a very simple script will generate the XML list on the fly, you just have to configure the URL of this script in AppMobile and it's done. In practice, this must be the case if you already have a website running.
In both cases, let's begin with a description of the XML format for AppMobile lists.
General format description
An example of XML file: the following defines a list of 3 items.
<?xml version="1.0" encoding="UTF-8"?> <items version="1.0" type="1" reload="1" locate="1"> <!-- items type : 1 = standard list reload : 1 = Reload each show, 0 = No reloading locate : 1 = User can locate the list, 0 = User can't locate the list --> <item type="1"> <!-- item type : 1 = item with image, 2 = item without image --> <img>http://image1.notulus.com/photos/article_news/Concorde2014_100x75.jpg</img> <!-- Image should be 80x60px for correct display --> <txt1>Concorde</txt1> <txt2>Nouvel EP</txt2> <txt3>Musique</txt3> <link type="1" url="http://www.notulus.com/iphoneV2/iphone_affiche_news.php?id=3917" title="News - Musique"/> <!-- link type : 1 = url to html content, 4 = url to xml sub-list --> </item> <item type="1"> <img>http://image1.notulus.com/photos/article_news/FestivalGerardmer2014_100x75.jpg</img> <txt1>Festival de Gérardmer</txt1> <txt2>Palmarès</txt2> <txt3>Cinéma</txt3> <link type="1" url="http://www.notulus.com/iphoneV2/iphone_affiche_news.php?id=3914" title="News - Cinéma"/> </item> <item type="2"> <img/><!-- no image for item type = 2 --> <txt1>Nos coups de coeur à l'affiche</txt1> <txt2>Cinéma</txt2> <txt3>(sous-liste)</txt3> <link type="4" url="http://fpierrat.fr/xml/exemple/sous-liste-exemple.xml" title="A l'affiche"/> </item> </items>
The file structure is really simple. The list is represented by a <items> element, which contains one <item> node for each entry of the list.
Each item contains an <img> thumb, one, two or three text lines (<txt1>, <txt2> and <txt3>) and one <link> which defines the action to be taken when the user taps on this entry in the list.
You can have links pointing either to a HTML page, or to a XML sub-list.
(cf. attribute <link type="...">)
The attribute <item type="..."> also covers specific needs, like adding items to a shopping-cart:
Note:The structure described above refers to an <items version="1.0"> list.
To group items in sections, use an <items version="1.1"> list (detailed specifications follow for both variants).
The <items> element
Content
A list of <item> elements (version 1.0) or <section> elements (version 1.1).
Attribute : "version" :
- "1.0" = list of items.
The <items> list contains <item> elements. - "1.1" = list of items grouped by sections.
The <items> list contains <section> elements which in turn contain <item> elements.
Attribute : "type" :
- "1" = standard list.
This is the only reserved value for now.
Attribute : "reload" :
- "1" = automatically reload the list.
Each time this list is displayed, the XML is reloaded from the server first. - "0" = do not reload [default value].
The list is loaded once the first time that the list is displayed, and stored locally on the phone. The next times the list gets displayed, the locally stored data will be displayed without any further server call.
To avoid unnecessary server communication delays, "reload" should be set to "0" for static lists, or dynamic lists based on an unfrequently updated data sources.
"reload" should be set to "1" only for dynamic lists based on frequently updated data, or lists whose contents may be modified by user's actions (a shopping cart should always be reloaded for instance).
Attribute : "locate" :
- "1" = Geo-localization button available
The geoloc button appears in the title bar of the application. Users can activate it (it becomes green) or deactivate it (red).
When geoloc is activated, the app passes the smartphone's geographic coordinates as GET parameters when calling the URL of the XML list. For dynamic lists (generated by a sever-side script), the coordinates passed to the script allow to deliver specific contents depending on the user's posiiton (nearest shops, events, other users...). - "0" = No geo-localization button
The user cannot activate geolocalization for this list.
The application won't communicate any GPS coordinates.
The <section> element
The <section> element is only defined in version 1.1 (version="1.1" attribute of <items>).
It is mandatory: an <item> element cannot be placed directly in the <items> element in version 1.1, it must be placed in a <section> element.
It is aimed at displaying grouped blocks of <item> elements: articles by categories, news by themes, etc....
Content
A list of <item> elements.
Attribute : "title" :
This is the text of the heading that will be displayed for this section.
The <item> element
Content
The <item> element contains following child nodes :
- <img> : contains the URL of the thumbnail.
It must be a .jpg or .png picture with a width of 80px and a height of 60px.
It is important to respect this resolution or the image will be resized, resulting in eventual distorsions, not even speaking of downloading delay increase for bigger files on mobile networks. - <txt1>, <txt2> and <txt3> : You can display up to 3 lines of text per item.
None of them is mandatory, you can make any combination of them depending on the data to be displayed and your layout preferences. - <link> : The URL which will be called when the user selects this item.
See below for further explanation about the <link> element.
Attribute : "type" :
- "1" = with thumbnail.
- "2" = without any picture.
The <link> element
Content
The<link> element is empty.
Attribute : "type" :
- "1" = HTML page : selection of this item will open the HTML page pointed by the "url" attribute.
- "4" = XML sub-list : when the user selects this item, a new list will be opened.
The content of this sub-list is defined in the XML file (static or dynamic) pointed by the "url" attribute.
Attribute : "url" :
The "url" attribute contains the URL that is called when the user selects this item in the list.
Attribute : "title" :
The "title" attribute contains the text that will be shown in the title-bar of the called page (HTML page or XML sub-list).