Hashtable Point of Interest
While working on the development of a relatively simple navigation/tab control I have come accross the following issue:
Navigation control contains buttons on the navigation bar, and by clicking on them the appropriate panel appears.
I wanted to save which panel appears by clicking a certain button in hashtable.
The button was supposed to be the hashtable’s key, while the panel its value.
Although my solution worked perfectly in the MobiAccess emulator, on Android phones a "java.lang.NullPointerException - null" error message appeared when I tried to add the button-panel pair to the hashtable: hashtable.Add(button, panel);
I wrote a little test that I used to examine which keys cause the error:
var hashTable:HashTable = HashTable.CI();
//it is working
//exception occured on android
MessageBox.Show("SUCCESSFUL", "Item Added", EMessageBoxButtons.OK); }
MessageBox.Show("ERROR", ex.GetMessage(), EMessageBoxButtons.OK); }
It is intriguing that although the mainform does not cause an issue, all the other standard controls (button, label, textbox) do.
I created a class (NavigationItem), which contains a Button and a Panel variable.
I stored these navigation items in a List type object. Implicitly an add and a get method was required for this, meaning that I practically mimicked the functioning of the hashtable.
According to the MobiAccess developer team the issue has been solved, and it will not reemerge from the next release.
Written by PK