I want to create menu from XMLFile. My xml is like this
<?xml version="1.0" encoding="UTF-8"?>
<root>
<parent title="Layanan Anda">
<menu title="Info Kartu">
<submenu title="Informasi Saldo">
<input type="numberpassword" length="4">Kode </input>
</submenu>
<submenu title="Mutasi Kartu Utama">
<input type="numberpassword" length="4">Kode </input>
</submenu>
<submenu title="Mutasi Kartu Lain">
<input type="number" length="10">Kartu</input>
<input type="numberpassword" length="4">Kode </input>
</submenu>
<submenu title="Deposito">
<input type="number" length="10">Bilyet</input>
<input type="numberpassword" length="4">Kode </input>
</submenu>
</menu>
<menu title="Kartu Anda">
</menu>
<menu title="Other Info">
</menu>
<menu title="Isi">
</menu>
</parent>
<parent title="Menu Favorit">
</parent>
<parent title="Recent Menu">
</parent>
<parent title="Setting">
</parent>
</root>
In HomeScreen, list menu parent will show first. And when I click parent menu, application will show list menu from "menu" tag. When I click menu again, application will show list menu from submenu. And vice versa when I want to back to parent menu.
How can I implement this in J2ME?
Parse your XML file and create a tree structure to hold the menu/submenu items. Each node should hold the items of a single level. For example:
Then use a graphical List to show the items of a node.