08-20-2010 04:55 AM
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
08-20-2010 05:10 AM
hi,
LabelField tabHome = new LabelField("HOME",Field.FOCUSABLE)
{
protected boolean navigationClick(int status,int time)
{
// write your code on click
return true;
}
};
Thansk
Ekansh
04-07-2011 10:23 PM
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?
04-08-2011 05:24 AM
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.
04-08-2011 06:34 AM
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...
04-08-2011 03:34 PM
04-10-2011 09:12 PM
04-12-2011 06:09 PM
Excellent.
Can you mark this as solved please?
04-13-2011 06:25 PM
04-14-2011 02:25 AM
You are rifght, you can't.