BlackBerry Development achieves Tabbed Pane effect similar to Lwuit

Source: Internet
Author: User

This article will focus on the implementation of Tabbed Pane similar to Lwuit in the Development of Black Berry. Although Lwuit has the version of Black Berry, it combines different system versions of all versions, including QWERTY, suretype, and touch, to make cropping very difficult.

BlackBerry Development achieves TabbedPane effect similar to Lwuit

Although Lwuit has a version developed by BlackBerry, after analyzing its source code, it is found that it cannot be directly applied to actual projects, it combines different system versions of all versions, including QWERTY, suretype, and touch, to make cropping very difficult. The current design structure is not very clear, so the source code cropping process is chaotic. Although blackberryUI does not provide paging effects similar to Lwuit, we can use the existing API to perform simple imitation. Wait for some difficult problems to solve, and then study them slowly...

Two implementation methods:

1. Use Screen switching;

2. Use Graphics encapsulation.

Both methods use the navigationMovement () Event Response Function of the scroll wheel. Therefore, you must rewrite the event on the screen to be switched.

◆ Implementation 1: use Screen Switching

Idea: First press the two screens into the stack in the constructor of UiApplication. Then create two Sreen and rewrite the navigationMovement () method in each Screen. Obtain the UiApplication object in navigationMovement () and call UiApplication. pushScreen () to push another interface to the stack. In another interface, call UiApplication. popScreen () to bring up the stack.

Code in the first screen:

 
 
  1. Viewplaincopytoclipboardprint?
  2. /*
  3. * Scroll event response
  4. * Scroll wheel action: upward dy =-1, downward dy = 1, left dx =-1, right dx = 1
  5. * @ Seenet. rim. device. api. ui. Screen # navigationMovement (int, int)
  6. */
  7. ProtectedbooleannavigationMovement (intdx, intdy, intstatus, inttime ){
  8. // Dialog. alert ("TrackBallmoved: \ r \ n" + "x:" + dx + "\ r \ ny:" + dy );
  9. If (dx> 0 & this. isDisplayed ()){
  10. SillyDowntheApp = (SillyDown) this. getApplication ();
  11. TheApp. popScreen (theApp. getFirstScreen ());
  12. Returntrue;
  13. }
  14. Returnfalse;
  15. }
  16. /*
  17. * Scroll event response
  18. * Scroll wheel action: upward dy =-1, downward dy = 1, left dx =-1, right dx = 1
  19. * @ Seenet. rim. device. api. ui. Screen # navigationMovement (int, int)
  20. */
  21. ProtectedbooleannavigationMovement (intdx, intdy, intstatus, inttime ){
  22. // Dialog. alert ("TrackBallmoved: \ r \ n" + "x:" + dx + "\ r \ ny:" + dy );
  23. If (dx> 0 & this. isDisplayed ()){
  24. SillyDowntheApp = (SillyDown) this. getApplication ();
  25. TheApp. popScreen (theApp. getFirstScreen ());
  26. Returntrue;
  27. }
  28. Returnfalse;
  29. }
  30.  
  31. Code in the second screen:
  32.  
  33. Viewplaincopytoclipboardprint?
  34. /*
  35. * Scroll event response
  36. * Scroll wheel action: upward dy =-1, downward dy = 1, left dx =-1, right dx = 1
  37. * @ Seenet. rim. device. api. ui. Screen # navigationMovement (int, int)
  38. */
  39. ProtectedbooleannavigationMovement (intdx, intdy, intstatus, inttime ){
  40. // TODOAuto-generatedmethodstub
  41. If (dx <0 & this. isDisplayed ()){
  42. SillyDowntheApp = (SillyDown) this. getApplication ();
  43. TheApp. pushScreen (theApp. getFirstScreen ());
  44. Returntrue;
  45. }
  46. Returnfalse;
  47. }
  48. /*
  49. * Scroll event response
  50. * Scroll wheel action: upward dy =-1, downward dy = 1, left dx =-1, right dx = 1
  51. * @ Seenet. rim. device. api. ui. Screen # navigationMovement (int, int)
  52. */
  53. ProtectedbooleannavigationMovement (intdx, intdy, intstatus, inttime ){
  54. // TODOAuto-generatedmethodstub
  55. If (dx <0 & this. isDisplayed ()){
  56. SillyDowntheApp = (SillyDown) this. getApplication ();
  57. TheApp. pushScreen (theApp. getFirstScreen ());
  58. Returntrue;
  59. }
  60. Returnfalse;
  61. }

Comment: This implementation method is relatively simple, but the effect is average.

◆ Implementation 2: Graphics Encapsulation

Idea: use Graphics to encapsulate a LabelField and then redraw each Field in the navigationMovement () method.

Code: writing. Mark it first)

Comment: You can use this method to encapsulate a TabbedPane. You can set the UI color, width, height, and font. The interface is gorgeous, but the code is complicated.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.