development

Blackberry Applications

Posted on August 7, 2009. Filed under: blackberry, development | Tags: , |

“The secret to winning at roulette is to know when you are ahead.”

First off, this post is more touchy-feely than about any concrete details.  It is more a summary of what has worked and what hasn’t worked.  Later on I will go into more code details but I wanted to get some initial thoughts out.

Well, here I am a week or so later and I have made some great strides forward.  I have been working on a crazy little app that takes a phone number, decodes from the number to letters and displays a list of the resulting ‘words’.

For example: 228 –> { abc, abc, tuv } provides {aat, aau, aav, abt, abu, abv, act, acu, acv, bat, bau, bav, bbt, bbu, bbv, cat, cau, cav, cbt, cbu, cbv, cct, ccu, ccv }

It isn’t terribly useful but it provides a framework to explore the API and learn how to put the pieces together.

Some of the things that I have learned:

  1. Managers are important
  2. Creating your own custom controls by overriding the basic ‘field’  controls are essential
  3. If you want to impress people then you must know about paint()ing
  4. That people are quite forgiving and accepting on the blackberry forums

Importance of managers

It is debatable on whether PHBs are important in any role other than to provide a focus of scorn and ridicule from their employees.  Hey wait a minute, I’m not talking about that talk of manager; I’m talking about this type of manager.

I learned that to correctly position, navigate and style an application you have to understand how the managers work.  I started out by using verticalFieldManager and horizontalFieldManagers to get the layout that I wanted.  However, I ran into problems creating the style that I desired.  I often had colours not extending the full width of the screen or I had navigation issues or the controls were all left-aligned.

Now, looking back, I’m sure that I could have used the provided managers and just provided my own delegates during construction.  However I decided to create my own custom manager and that made a huge difference in reaching my goal of learning about the framework and getting the app looking and reacting how I wanted it to. 

I will definitely give details on my manager experience in a future discussion.

Creating custom controls

As you can imagine with an application that takes in a phone number, I had to have quite a few buttons that match up with a phone’s keypad.  I started out using the ButtonField but it quickly became evident that I would have problems with colours and event handling. 

I decided to override the base ‘Field’ class and create my own button.  It was quite simple, once I learned how to override essential base methods.

  • getPreferredWidth – used to set the width of your field
  • getPreferredHeight – used to set the height of your field
  • layout – used to set the ‘extent’ of your control
  • paint – oh, the key stone of functions
  • onFocus – fires when field receives focus
  • onUnFocus – fires when field loses focus
  • keyChar – fires when field receives a key event
  • navigationClick – fires when field receives a wheel or touch event

Paint, Paint, Paint

Oh yes, get to know it, get to love it, get to hate it.  In my brief experience, this is THE function to know about if you want your application to look anything other than a VT100 terminal application.  Obviously, this is where you create your own look and feel and impose your style ideals on your unsuspecting customers.

Oh, when you look into this function, also get to learn about Graphic class and how to create your own contexts

Blackberry forums

While searching for how to accomplish my goals I have read many a post where individuals asked and (much to my surprise) received help.

I must say that people on the forums are very forgiving and accepting and generally helpful.  The main challenge that I have found is typing the correct keywords into Google to find the appropriate thread.

Technorati Tags: ,
Advertisements
Read Full Post | Make a Comment ( None so far )

Liked it here?
Why not try sites on the blogroll...