Advertisement
alishaik786

SplashScreeExample

Jan 12th, 2012
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.75 KB | None | 0 0
  1. //-----------------------------------------StartUp.java-------------------
  2. import net.rim.device.api.ui.UiApplication;
  3. import net.rim.device.api.ui.component.Dialog;
  4.  
  5. public class StartUp extends UiApplication
  6. {
  7. public static void main(String[]ali)
  8. {
  9. StartUp start=new StartUp();
  10. start.enterEventDispatcher();
  11. }
  12. public StartUp()
  13. {
  14. this.pushScreen(new SplashScreen());
  15. invokeLater(new Runnable()
  16. {
  17. public void run()
  18. {
  19. try
  20. {
  21. Thread.sleep(2000);
  22. UiApplication.getUiApplication().popScreen(UiApplication.getUiApplication().getActiveScreen());
  23. pushScreen(new FirstScreen());
  24. }
  25. catch (Exception e)
  26. {
  27. exceptionHandling(e.getMessage());
  28. }
  29. }
  30. });
  31.  
  32. }
  33.  
  34. public static void exceptionHandling(final String exception)
  35. {
  36. UiApplication.getUiApplication().invokeLater(new Runnable()
  37. {
  38. public void run()
  39. {
  40. Dialog.alert(exception);
  41. }
  42. });
  43. }
  44. }
  45.  
  46. //------------------------------SplashScreen.java---------------------------
  47.  
  48. import net.rim.device.api.system.Bitmap;
  49. import net.rim.device.api.system.Display;
  50. import net.rim.device.api.ui.Graphics;
  51. import net.rim.device.api.ui.component.BitmapField;
  52. import net.rim.device.api.ui.container.MainScreen;
  53. import net.rim.device.api.ui.container.VerticalFieldManager;
  54.  
  55. public class SplashScreen extends MainScreen
  56. {
  57. Bitmap bitmap=Bitmap.getBitmapResource("loading-screen.png");//This is my company logo;
  58. BitmapField loadingImage=new BitmapField(bitmap);
  59. public SplashScreen()
  60. {
  61. createGUI();
  62. }
  63.  
  64. private void createGUI()
  65. {
  66. try
  67. {
  68. VerticalFieldManager vertical=new VerticalFieldManager()
  69. {
  70. protected void paint(Graphics g)
  71. {
  72. g.drawBitmap(0, 0,Display.getWidth(),Display.getHeight(), bitmap, 0, 0);
  73. super.paint(g);
  74. }
  75. protected void sublayout(int maxWidth, int maxHeight)
  76. {
  77. super.sublayout(Display.getWidth(),Display.getHeight());
  78. setExtent(Display.getWidth(),Display.getHeight());
  79. }
  80. };
  81.  
  82. // Nothing to write;
  83.  
  84. add(vertical);
  85. }
  86. catch (Exception e)
  87. {
  88. StartUp.exceptionHandling(e.getMessage());
  89. }
  90. }
  91. }
  92.  
  93. //---------------------------FirstScreen.java
  94.  
  95. public class FirstScreen extends MainScreen
  96. {
  97. VerticalFieldManager vertical;
  98.  
  99. public FirstScreen()
  100. {
  101. createGUI();
  102. }
  103.  
  104. private void createGUI()
  105. {
  106. setTitle("Loading Screen");
  107. vertical=new VerticalFieldManager()
  108. {
  109. protected void sublayout(int maxWidth, int maxHeight)
  110. {
  111. super.sublayout(Display.getWidth(),Display.getHeight());
  112. setExtent(Display.getWidth(),Display.getHeight());
  113. }
  114. };
  115. add(vertical);
  116. }
  117.  
  118. public boolean onMenu(int instance)
  119. {
  120. return true;
  121. }
  122. }
  123.  
  124. //-------------------- Try this;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement