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

Regular Contributor
Posts: 55
Registered: ‎09-01-2010
My Device: Not Specified

Blackberry RichTextField focus problem

I am using following code for a listing. I have used `RichTextField` for items of list.

    public class ListScreen extends MainScreen {
        private UiApplication application;
        private VerticalFieldManager listManager;
        public ListScreen() {
                    | USE_ALL_WIDTH);
            // TODO Auto-generated constructor stub
            this.application = UiApplication.getUiApplication();
            LabelField screenHeading = new LabelField("Category",
                    FIELD_HCENTER) {
                protected void paint(net.rim.device.api.ui.Graphics g) {
            final VerticalFieldManager labelMngr = new VerticalFieldManager(USE_ALL_WIDTH);
            labelMngr.setPadding(5, 0, 5, 0);
            try {
                listManager = new VerticalFieldManager(Manager.VERTICAL_SCROLL
                        | Manager.VERTICAL_SCROLLBAR) {
                    protected void sublayout(int maxWidth, int maxHeight) {
                        int width = Display.getWidth();
                        int height = Display.getHeight()
                                - labelMngr.getHeight();
                        super.sublayout(width, height);
                        setExtent(width, height);
                listManager.setPadding(5, 0, 5, 0);
                int i=0;
                RichTextField rtf;
                Background background = BackgroundFactory
                Border border = BorderFactory.createSimpleBorder(new XYEdges(0, 0,
                        2, 0));
                CategoryHelper categoryHelper = new CategoryHelper();
                final String[][] cetegoryList = categoryHelper.getCategoryList();
                for(; i < cetegoryList.length ; i++) {
                    rtf = new RichTextField(cetegoryList[i][1], Field.FOCUSABLE) {
                        protected boolean navigationClick(int status, int time) {
                            return true;
                        protected boolean touchEvent(
                                net.rim.device.api.ui.TouchEvent message) {
                            if (TouchEvent.CLICK == message.getEvent()) {
                                FieldChangeListener listener = getChangeListener();
                                if (null != listener)
                                    listener.fieldChanged(this, 1);
                            return super.touchEvent(message);
                    rtf.setBackground(Field.VISUAL_STATE_NORMAL, background);
                    rtf.setPadding(1, 2, 1, 3);
                    rtf.setCookie(new Category(Integer.parseInt(cetegoryList[i][0]),cetegoryList[i][1]));
                    rtf.setChangeListener(new FieldChangeListener() {
                        public void fieldChanged(Field field, int context) {
                            // Dialog.alert("play the video");
                            // System.out.print("play the video");
                            // code for play video
                if (i == 0) {
                    listManager.add(new RichTextField("No word found."));
            } catch (Exception e) {


It is working fine for simulator. I can scroll the list and can set the focus on any item by scrolling and focused item get blue mark. But when I am testing BB device, the item is focused, but the focused state is not visible and unchanged in color which means the user cannot identify which one is focused. What is problem in my code?

BlackBerry Development Advisor
Posts: 15,760
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: Blackberry RichTextField focus problem

Which BlackBerry Smartphone model and BlackBerry handheld software version are you testing on?  You can find this under Options, About on the BlackBerry Smartphone.


You are capturing touch events in the code snippet above, does the BlackBerry Smartphone you are testing on also have a touch screen?

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker