开发者

Dynamically create android layout or menu from a JSON string

Would it be possible to on app start send a request to a server which would return JSON. The JSON would contain something like:

{
“option”: [
    { “id”: “1”,  “text”: “m开发者_运维百科enuoption1” , “page”:”page1” },
    { “id”: “2”,  “text”:  “menuoption2”, “page”:”page2 “ },
    { “id”: “3”,  “text”:  “menuoption3” , “page”:”page3” },
    { “id”: “4”,  “text”:  “menuoption4” , “page”:”page4” },
],

The application would then parse this and create a menu from it? Would I somehow send this to an xml file to dynamically create the layout?

EDIT: Just brainstorm a bit with me...but I suppose for the various "menu objects" created I could create custom view classes which I then populate with the returned json and then add programmatically to the layout?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜