Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
New Developer
frankkona
Posts: 24
Registered: ‎10-01-2009
My Device: Not Specified

BitmapField navigationClick()

I have added Bitmapfield on my VerticalFieldManager. Bitmap is showing correctly. I also set it BitmapField.FOCUSABLE and added navigationClick() to receive event when pressed. Only problem I am having now is - BitmapField has some sort of ID and name fields. so navigatonClick should receive those attributes to distinguish one bitmap from another. Question is how can i pass values inside navigationClick(). here is my code -

 

//Global

_sProjectID = "";

_sTaskID = "";

 

  BitmapField bmpField = new BitmapField(loader, BitmapField.FOCUSABLE)
                                     {
                                            public void setFocusable(boolean value)
                                            {
                                                _sProjectID = "100";
                                                _sTaskID = "200";
                                            }

                                             protected boolean navigationClick( int status, int time ){

                                               if(_instance!= null)
                                               {
                                                   _instance.switchFromProjectTaskToProjectInfo(_sProjectID,_sTaskID);


//GETTING empty strings for both sProjectID and sTaskID

                                              }
                                               return true;
                                            }

Please use plain text.
Developer
peter_strange
Posts: 19,601
Registered: ‎07-14-2008
My Device: Not Specified

Re: BitmapField navigationClick()

Rather than setFocusable, I think you want to code that sets the global values in the onFocus method.

 

However I have to say I don't like this approach, doesn't seem very Object Friendly.  If the ProjectID and taskId are attributes of the Button, then they should be stored with the button.  But if it works for you...

Please use plain text.
Developer
RexDoug
Posts: 4,764
Registered: ‎07-21-2008
My Device: Not Specified

Re: BitmapField navigationClick()

Why don't you call getFieldWithFocus() in your navigationClick method, and compare the Field object with your bitmap references?

 

 

field = getFieldWithFocus();

if (field == bitmap1){

   // do something

}

else if (field == bimap2){

  // do something else

}

 

Please use plain text.
New Developer
frankkona
Posts: 24
Registered: ‎10-01-2009
My Device: Not Specified

Re: BitmapField navigationClick()

>>If the ProjectID and taskId are attributes of the Button,

 

How can you add those attributes to a control object like Button or LabelField? I changed the code now navigationClick is called from a LabelField but not a bitmapfield. I am still not able to get the those values. I do get values but I get the very last values In other word, I have list of labelfields they are populated inside a for loop.

 

   for(int j=0; j< TaskArray.size();j++)
                {
                    _task = (Task) TaskArray.elementAt(j);


               String sProjectID = (String)_task.ProjectID;

                String sTaskID = (String)_task.TaskID:

               String sLabelName = (String)_task.LabelName;

             LabelField _labelField = new LabelField(sLabelName, LabelField.FOUSUABLE);

            add(_labelField);

 

Also, it is too late, I canot use ListField. I am using bunch of Labelfields.

 

 

Please use plain text.
Developer
peter_strange
Posts: 19,601
Registered: ‎07-14-2008
My Device: Not Specified

Re: BitmapField navigationClick()

Yo might consider RexDougs option rather than what I suggested.

 

The way I would have done this is to create an extension of the target Field and set attributes for it.

 

For example, here is a LabelField that might do something like what you want.  Most likely it won't compile, but you get the idea.

 

class MyLabelField extends LabelField {
    String _sProjectID;
    String _sTaskID;
    public MyLabelField(String label, long style, String sProjectID, String sTaskID ) {
        super(label, style;
        _sProjectID = sProjectID;
        _sTaskID = sTaskID;
    }
    protected boolean navigationClick( int status, int time ) {
        if(_instance!= null) {
            _instance.switchFromProjectTaskToProjectInfo(_sProjectID,_sTaskID);
        }
        return true;
    }
}

 

 

 

Please use plain text.