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 Contributor
madhabi
Posts: 4
Registered: ‎07-22-2010
My Device: Not Specified

clickable label field

hi

in my application i want to add a label which will have the click event. i tried to make the customButtonField, but in that the button looks still comes. What i want is a label which when clicked performs some functions. Is it possible? 
Does anybody have any idea.

thanks in advance.

madhabi

Please use plain text.
Developer
Ekansh
Posts: 468
Registered: ‎08-07-2009
My Device: Curve, Bold, Storm

Re: clickable label field

hi,

 

 

           LabelField  tabHome = new LabelField("HOME",Field.FOCUSABLE)
                                {
                                    protected boolean navigationClick(int status,int time)
                                    {
                                        // write your code on click
                                        return true;
                                    }
                           
                                };

 

 

Thansk

Ekansh

 

----------------------------------------------------------
feel free to press the kudos button on the left side to thank the user that helped you.
please mark posts as solved if you found a solution.
Please use plain text.
Developer
angelo_f
Posts: 64
Registered: ‎05-06-2009
My Device: Not Specified

Re: clickable label field

I tried this an it worked on a single field. However, I tried to extend it by doing it on more than one field

eg

        _authorTab = new LabelField("Author", Field.FOCUSABLE | Field.HIGHLIGHT_SELECT )
        {
            protected boolean navigationClick(int status,int time)
            {
                displayauthorTab();
                return true;
            }
            
        };
        
        _fileManagementTab = new LabelField("File Management", Field.FOCUSABLE | Field.HIGHLIGHT_SELECT)
        {
            protected boolean navigationClick(int status,int time)
            {
                displayFilemanagementTab();
                return true;
            }
        };

When I do this, the code does not do a new build (the same code is on teh simulator) - if I have more than one label field with the navigation click even if I comment out the calls.

        _authorTab = new LabelField("Author", Field.FOCUSABLE | Field.HIGHLIGHT_SELECT )
        {/*
            protected boolean navigationClick(int status,int time)
            {
                displayauthorTab();
                return true;
            }
            */
        };
        
        _hTabManager .add(_authorTab);

        _fileManagementTab = new LabelField("File Management", Field.FOCUSABLE | Field.HIGHLIGHT_SELECT)
        {/*
            protected boolean navigationClick(int status,int time)
            {
                displayFilemanagementTab();
                return true;
            }*/
        };

It still fails. I need to remove the brackets around all but one to make it build new code. eg

        _authorTab = new LabelField("Author", Field.FOCUSABLE | Field.HIGHLIGHT_SELECT );

        _fileManagementTab = new LabelField("File Management", Field.FOCUSABLE | Field.HIGHLIGHT_SELECT)
        {
            protected boolean navigationClick(int status,int time)
            {
                displayFilemanagementTab();
                return true;
            }
        };


Is there a bug in the compiler or is what I am trying to do not supported?

Please use plain text.
Developer
arindamhit
Posts: 271
Registered: ‎12-24-2010
My Device: BlackBerry 10

Re: clickable label field

Hi,

 

I suggest you create some custom label field and use this label for different purpose.

 

public class LabelFieldCustom extends LabelField {

 

 public LabelFieldCustom( String text, int color, long style)

{

 

}

 

There in the class you can put the navigationClick( ) method. I hope it will work. Check it.

 

Please use plain text.
Developer
rohit_marumamula
Posts: 29
Registered: ‎03-10-2011
My Device: Not Specified

Re: clickable label field

Hi, I tried small bit of code and its working fine.. Check this out..

 

 

 

class MyScreen extends MainScreen

 

{

 

   LabelField label=new LabelField("click",LabelField.FOCUSABLE);

 

Myscreen()

 

{

 

   add(label);

 

   label.setFocusListener(listen);

 

}

 

 

 

FocusChangeListener listen=new FocusChangeListener()

 

{

   public void focusChanged(Field field,int eventType)

   {

     if(field==label)

     {

       Dialog.alert("Label clicked");

     }

   }

};

Hope this code will help you...

Please use plain text.
Developer
angelo_f
Posts: 64
Registered: ‎05-06-2009
My Device: Not Specified

Re: clickable label field

I ended up using this solution.
Please use plain text.
Developer
angelo_f
Posts: 64
Registered: ‎05-06-2009
My Device: Not Specified

Re: clickable label field

The actual problem is defined at this link below. http://supportforums.blackberry.com/t5/Java-Development/Eclipse-wont-build/td-p/418217 It seems that by adding the navigationClick event or even just the braces added an extra class and made me jump above the 71 class bug (defined in the link above). I defined the JDK path in my system path variable and it now works.
Please use plain text.
Developer
peter_strange
Posts: 19,607
Registered: ‎07-14-2008
My Device: Not Specified

Re: clickable label field

Excellent.

 

Can you mark this as solved please?

Please use plain text.
Developer
angelo_f
Posts: 64
Registered: ‎05-06-2009
My Device: Not Specified

Re: clickable label field

I can't see where to mark it solved. I didn't create the thread - is that sopping me from having an option to mark it solved?
Please use plain text.
Developer
peter_strange
Posts: 19,607
Registered: ‎07-14-2008
My Device: Not Specified

Re: clickable label field

You are rifght, you can't.

Please use plain text.