listview - Create custom list using json data in Blackberry 10 using QML -
i getting json info web service below:
"list1": [ { "id": "1", "title": "title1", "picture":"myurl" }, { "id": "2", "title": "title2", "picture":"myurl" } ]
now, want create custom listview
using json data, title , image.
i have tried many examples this. of links given below:
http://qt-project.org/wiki/jsonlistmodel http://developer.blackberry.com/native/documentation/cascades/device_platform/data_access/using_data_source.html
but, still cannot find solutions. can please help me solve issue?
creating list simple plenty task. it's bit harder because want show image internet, have utilize custom class this. download webimageview.cpp , webimageview.h , add together them within /src
directory (if want take @ whole project or follow steps).
add next within applicationui.cpp
include new class
#include "webimageview.h"
and within applicationui(bb::cascades::application *app)
add
qmlregistertype<webimageview>("org.labsquare", 1, 0, "webimageview");
so qml can access class.
this finish working sample of qml:
import bb.cascades 1.2 import bb.data 1.0 import org.labsquare 1.0 navigationpane { id: nav page { container { listview { datamodel: datamodel listitemcomponents: [ listitemcomponent { type: "item" content: container { label { text: listitemdata.title } webimageview { url: "http://adev.si/files/"+listitemdata.picture } } } ] attachedobjects: [ groupdatamodel { id: datamodel grouping: itemgrouping.none }, datasource { id: datasource source: "http://adev.si/files/somedata.json" remote: true ondataloaded: { datamodel.insertlist(data.list1) } } ] } } } oncreationcompleted: { datasource.load(); } }
i hope helped. need within .pro file
libs += -lbbdata qt += network
if want can import project , utilize it.
json listview qml blackberry-10 momentics
No comments:
Post a Comment