Advertisement
alishaik786

ListField.java

Jan 31st, 2012
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.20 KB | None | 0 0
  1. import java.util.Vector;
  2.  
  3. import net.rim.device.api.system.Display;
  4. import net.rim.device.api.ui.Graphics;
  5. import net.rim.device.api.ui.component.ListField;
  6. import net.rim.device.api.ui.component.ListFieldCallback;
  7. import net.rim.device.api.ui.container.MainScreen;
  8.  
  9. public class More extends MainScreen
  10. {
  11. private ListField _listField;
  12. private Vector _listElements;
  13. int current_index=0;
  14. BottomPanel bottomPanel;
  15. String userid,customerid,password,result;
  16. static String customer,user,pwd;
  17. ListCallback _callback;
  18. String name[]={"Home","Away","Settings","Help","About us","Log out"};
  19.  
  20. public More(String customerid,String userid,String password,int current_index)
  21. {
  22. this.current_index=current_index;
  23. customer=customerid;
  24. user=userid;
  25. pwd=password;
  26. createGUI();
  27. }
  28.  
  29. public void createGUI()
  30. {
  31. setTitle("MORE Screen");
  32. bottomPanel=new BottomPanel(current_index);
  33. _listElements = new Vector();
  34. initializeList();
  35. _callback = new ListCallback();
  36. _listField = new ListField()
  37. {
  38. protected boolean navigationClick(int status, int time)
  39. {
  40. StartUp.exceptionHandling("you selected index: "+name[_listField.getSelectedIndex()]);
  41. return super.navigationClick(status, time);
  42. }
  43. };
  44. _listField.setSize(_listElements.size());
  45. _listField.setCallback(_callback);
  46. add(_listField);
  47. setStatus(bottomPanel);
  48. }
  49.  
  50. private void initializeList()
  51. {
  52. for(int i=0;i<name.length;i++)
  53. {
  54. _listElements.addElement(name[i]);
  55. }
  56. }
  57. // protected boolean navigationClick(int status, int time)
  58. // {
  59. // StartUp.exceptionHandling("you selected index: "+name[_listField.getSelectedIndex()]);
  60. // return super.navigationClick(status, time);
  61. // }
  62. //
  63. private class ListCallback implements ListFieldCallback
  64. {
  65. public void drawListRow(ListField list, Graphics g, int index, int y, int w)
  66. {
  67. String text = (String)_listElements.elementAt(index);
  68. g.drawText(text, 0, y, 0, w);
  69. }
  70. public Object get(ListField list, int index)
  71. {
  72. return _listElements.elementAt(index);
  73. }
  74. public int indexOfList(ListField list, String prefix, int string)
  75. {
  76. return _listElements.indexOf(prefix, string);
  77. }
  78. public int getPreferredWidth(ListField list)
  79. {
  80. return Display.getWidth();
  81. }
  82. }
  83. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement