ObjectListField graphocs

Hello

I've seen some posts regarding the ObjectListField object use, but I have a question which I can not solve:

I've implemented my own ObjectListField and override the drawListRow function, because I want to set the font for the text

for each field based on its property (fonts bold or normal) however I have noticed that the police of the entire list is updated

instead of just the specific listField, I wanted to change.

Here is the code I use:

public void drawListRow(ListField listField, Graphics graphics, int index, int y, int width) {
    Vector aInfo = m_dcdr.getInfo();
    objElm aElm = (objElm)aInfo.elementAt(index);
    if (aElm == null)
        return;
    Vector aConv = aElm.getConv();
    if (aConv.size() == 0)
        return;

    objElmConvn aMsgConv = (objElmConv)aConv.elementAt(0);
    String showMsg = aMsgConv.getSender();
    String title = MSG_TITLE;
    graphics.drawText(title, 0, y, DrawStyle.ELLIPSIS, width);
    graphics.drawText(showMsg, 0, y + m_winListFields.getRowHeight() / 2, DrawStyle.ELLIPSIS, width);
    if (aElm.getBoolElm(ElementsID.ELM_READ) == false)
        graphics.setFont(m_boldFont);
    else
        graphics.setFont(m_plainFont);

}

Is someone can you please tell me why I can not set the font to each field?

Thank you.

I found the answer: just set the font differently for each text you add :-)

Tags: BlackBerry Developers

Similar Questions

  • Border ObjectListField

    Hello

    I can't draw a border around an ObjectListField. The border runs on the right side of the screen, with no visible straight edge. Any ideas on how to solve this problem? I tried a number of things and that you have not had success yet.

    This is the code for the for the ObjectListField layout() method:

    protected void layout(int width, int height)
    {
        super.layout(width, height);
        this.setMargin(5, 5, 5, 5);
        this.setPadding(5, 5, 5, 5);
        this.setExtent(Display.getWidth(), this.getContentHeight());
    }
    

    And the display will show as follows:

    Thank you

    Never mind. A stupid bug. Just changed the call setExtent to:

    this.setExtent (Display.getWidth () - 25, this.getContentHeight ());

    I was sure that I already tried, but anyway it works now...

    See you soon,.

  • Problem with the ObjectListField

    Hello

    I have problems with the method getSelectedIndex() ObjectListField.
    Supposedly, when there is no index selected, it returns-1. But how come it always returns the index of the last element?

    To illustrate, I created my own dialog that has similar functionality to the "device window select" Bluetooth BB application. I have an ObjectListField and a Cancel button. What I did simply, is to change the label of the button to show the selected index. I have attached my sample code below.

    public class MyDialog extends dialog
    {
    private ObjectListField m_list;
    private ButtonField m_btn;

    public MyDialog)
    {
    Super ("Select Device:", null, null, 0, Bitmap.getBitmapResource ("bluetoothIcon.PNG"), Manager.FOCUSABLE);

    m_List = new ObjectListField();
    m_btn = new ButtonField ("Cancel", Field.FIELD_HCENTER);
    m_List.set (new String [] {"first", "second"});

    Add (m_List);
    Add (m_btn);
    }

    protected boolean navigationClick (int status, int time)
    {
    m_btn.setLabel (Integer.ToString (m_List.getSelectedIndex ()));

    Returns true;
    }
    }

    Can someone help me on this problem? Is there something wrong with my code, or is the buggy API? All I want to do is to return an index of-1 if there is no selected item in the list.

    Also, I tried the isFocus() method to check if the list is being concentrated, it always returns false even if the list is OBVIOUSLY being focused. I'm running out of options on how to determine the solution to this problem. Help, please!

    Thank you very much.

    @jacylan - I do not use isFocus() to determine if the ListField is net.  Take a look at the following code, I think that with this, you can force-1 when the ListField is not the point.

        protected boolean navigationClick(int status, int time)
        {
            int selectedIndex = m_list.getSelectedIndex();
            boolean listInFocusOption1 = false;
            if ( this.getLeafFieldWithFocus() == m_list ) {
                listInFocusOption1 = true;
            }
            boolean listInFocusOption2 = false;
            if ( m_list.isFocus() ) {
                listInFocusOption2 = true;
            }
            m_btn.setLabel(Integer.toString(selectedIndex) + ":" + listInFocusOption1 + ":" +listInFocusOption2);
    
            return true;
        }
    
  • Customization of the user interface on Blackberry - ObjectListField

    Hello

    Someone has an idea how to deal with the following scenario with the ObjectListField on 4.5 OS worm. A simplest thing was to add the string with '\n', but it does not work with BB. Y at - there any option other to achieve this other than too much riding paint method?

    Scenario:

    Point 0: Label-10/12/2010

    String: This is the first element of the listfield.

    Point 1: Label-10 92 2010

    String: This is the second element of the listfield.

    .

    .

    .

    .

    .

    .

    .

    .

    the field seems to serve three times the rowheight fontsize.

    Use setRowHeight (getFont () .getSize () * 3) to achieve this goal.

    Now you can draw the lines using the y and adding the fontHeight to row2, row3 RESP.

    to get the update behavior, you must change the drawFocus method (it is a bit Advanced, it would be easier to let the entire marked input)

  • Display in the ObjectListField imageField

    I use JDE 5.0 which does not support the RichList so using the ObjectListField to display items title... as well as titles of the order of the day, I want to display their image... Is Howz possible... Help, please

    Welcome on the support forums.

    you do not include the field of the image, instead, you draw the image directly using graphics.drawBitmap in your drawListRow method.

  • How to position ListField or ObjectListField

    Nobody knows how to set the x, position y ListField or ObjectListField?

    I test on the Simulator Blackberry 9700 ATT, running OS 5.0.

    I am using an ObjectListField to create submenu in OS 5.0 and I put the width using getPreferredWidth(), so that it does not occupy the entire screen. So it's starting to look like a menu system, but it is default x, position is 0.0 and I need to change that.

    Thank you

    Steve

    setMargin works very well for this.

    You can use it like this

    myfield.setMargin (y, 0, 0, x); up, right, down, left

  • Label of the choice of the user of an objectlistfield element control knob

    Hello

    I'm a beginner and this is my first BB app. I have a problem and I tried to do on my own, done quite a bit of research, but could not find any solution.

    The thing is, I have a button on the main screen, was added by clicking this button, I push a popupscreen at the top of the stack that contains an ObjectListField. Now, I want to put the label of the button on the screen as the name of the selected field in the ObjectListField. I have attached my code on which I am experimenting and trying to learn (really enthusiastic about it ), so would appreciate any help in this regard. Thanks a ton

    package mypackage;
    
    import net.rim.device.api.ui.Field;
    import net.rim.device.api.ui.FieldChangeListener;
    import net.rim.device.api.ui.UiApplication;
    import net.rim.device.api.ui.container.*;
    import net.rim.device.api.ui.component.*;
    
    public final class MyScreen extends MainScreen
    {
    
        ButtonField btn;
        public MyScreen()
        {
            // Set the displayed title of the screen
            super();
            setTitle("MyTitle");
    
            btn=new ButtonField("Label",ButtonField.CONSUME_CLICK);
            btn.setChangeListener(new FieldChangeListener()
            {
                public void fieldChanged(Field field,int context){
    
                    UiApplication.getUiApplication().pushScreen(new mypopup());
    
                }
            });
    
                    add(btn);
    
        }
    
                /*public void inval(String lbl){
    
                    this.btn.setLabel(lbl);
                    this.invalidate();
                } */
    
    }
    
    class mypopup extends PopupScreen implements FieldChangeListener{
    
        String it;
    
    ObjectListField obj=new ObjectListField(){
    
            public boolean navigationClick(int status,int time){
    
                int selectedindex=obj.getSelectedIndex();
                 it=(String)obj.get(obj, selectedindex);
    
                UiApplication.getUiApplication().popScreen(UiApplication.getUiApplication().getActiveScreen());
    
            MyScreen my=new MyScreen();
                 my.btn.setLabel(it);
                my.invalidate();
    
        UiApplication.getUiApplication().invokeLater(new Runnable()
                {
                    public void run(){
    
                        Dialog.alert(it);
    
                    }
                });
    
                return true;        
    
            }
        };
    
         public mypopup() {
    
             super(new VerticalFieldManager(VerticalFieldManager.VERTICAL_SCROLL|VerticalFieldManager.VERTICAL_SCROLLBAR), Field.FOCUSABLE);
    
             String[] type=new String[] {"a","b","c","d"};
                obj.set(type);
                add(obj);
    
         }
    
        public void fieldChanged(Field field, int context) {
            // TODO Auto-generated method stub
    
        }
    
    }
    

    Hi Simon, first of all thanks a ton for the answer.

    I learned a lot by reading the documentation and links that you gave me.

    But the thing is, I really want to use the class popupscreen instead of the dialog box. So (with assistance), I made small changes in my code, and it seems to work now.

    I write changes in my code for other users who might have the same problem...

    I created a setlabel method (* not to be confused with setLabel), in the class MyScreen and right where I implement anti-pop mypopup class, I did...

    Scr Screen = UiApplication.getUiApplication () .getActiveScreen ();
    If (instanceof MyScreen scr) {}
    MyScreen my scr = (MyScreen);
    My.setLabel (IT);
    My.Invalidate ();

    Finally, it seems to work now.

    See you soon

  • Double line objectlistfield

    I have an objectlistfield which shows a bunch of selectable items that can be selected. The problem with this is that each text is very long and needs at least two lines and the objectlistfield seems not to support this feature. It cuts just text.

    I tried increasing the height of each line, but the text does not change its format. I read that possible solutions would be to replace the "drawListRow" of the objectlistfield but I can't figure out how to do it properly.

    I'll appreciate any type of help.

    First, you must set the line height. Usually, I take double the font size and add 2 for good measure.

    Now you can adjust the drawListRow. You get a parameter which determines where you are in your current line. drawText takes x and y as input. You can draw the first line by using drawText(5,y,text) and the second using drawText (5, y + listField.getRowHeight / 2, Text2). You must take care of a linebreak correct etc, I usually do with a StringTokenizer.

  • MainScreen.invalidate () seems to work very well, but not ObjectListField.invalidate)

    Hi, I hope just fast - is there a quirk with ObjectListField.invalidate () and invalidate (rowindex)?

    See you soon

    J

    Hey. Of course the Invalidate() rebuild fields, he redraws just them. The icon of hasbeenread had to be changed to drawlistrow, not disabling.

    J

  • ObjectListField separators

    I have an ObjectListField with a few dozen items in the list. I want to have a thin line that separates each item, similar to display it contacts and messages. What is the right way to do this?

    To come back to this a few weeks late.  I had to replace graphics and add the following line of code:

    graphics.drawLine(0, y, Display.getWidth(), y);
    
  • Strange: Objectchoicefield and ObjectListField in Gridfieldmanager - navigation problem

    Hi @all,

    I have a very strange problem, because running Simulator runs as I would have liked, but the device, the navigation is bad:

    running OS 5.0.0.42 3 on device (BB9700) and the Simulator

    1. the building screen

    2. put verticalfieldmanager on it that contains the background image

    3. put gridscreenmanager (with a column - the problem is with more then one column, too) on the first position of the vfm

    4. turn objectchoicefield with 5 points on the 1st row of the gsm

    5. put the objectlistfield with 5 points on the second line of gsm

    Program running in the Simulator:

    View all as I prefer.

    The first objectchoicefield and beyond the objectlistfield.

    When I scroll with trackpad OCF Gets the focus first and after that the olf on its first line.

    I can scroll up and down, and everything's fine.

    Program running on the device:

    View all as I prefer.

    The first objectchoicefield and beyond the objectlistfield.

    When I scroll with trackpad OCF Gets the focus first and after that the olf on its first line.

    So far so good:

    When I scroll down to the olf, all things are working properly. For example, point 4 a now focus.

    Now, if I try to go back in the OLF, it should go back to article 3 of the olf, but this is the leap into objectchoicefield. After that, if I try to go back to the objectlistfield, it jumps directly to point 4, which he came before.

    If I don't put the objectchoicefield in the first row, everything works fine.

    What can I do?

    I did something wrong?

    All ideas are very appeciated.

    Thanks in advance.

    CUA

    Michael

    Well, I found it.

    I made a mistake in the application of my own gridfieldmanager navigationmovement method.

    What is already strange: I used the same gridfieldmanager within 2 screens in my application. First screen was working fine, the second one was bad. Same content in both screens.

    Sorry for that.

    Thank you for all.

    CUA

    Michael

  • Need to call ObjectListField.setSelectedIndex (int) with holding EventLock

    Hello

    first of all I'm new here and I want to thank the forum a LOT as he already has helped me by just searching. Now I am facing a problem where I can't fiond one equivalent to the.

    I have read through several totorials how manipulate GUI (EventThread) and also through several topics on this site, so the idea of how doing this is familiar to me.

    I use a third-party library that is implemented with an Observer pattern to send events. On obtaining a particular event, I have to call the UI thread and display information on a screen changed.

    Now I do the error familiar "UIEngine" accessible without holding the lock of the event inside the invokeLater/invokeAndWait. How can this happen? Is it possible that it depends on the third my library event thread since it's the thread that calls?

    However, I found that with the help of snchronized (Application.getEventLock) {...}, no error is thrown, but ObjectListField.setSelectedIndex (int) is not working properly. It actually changes the index but do not display the change on the screen. So is it possible that changes in the return buffer, but not in the display buffer? Also tried to invalidate the entire list or only the selected item and was updated with

    UiApplication.getUiApplication () .updateDisplay (). Without success.

    Any suggestion would be appreciated. Thanks in advance.

    DoubleCheck if the object is really the same. singletons can be tricky in blackberry java!

  • User Guide for the decent ObjectListField?

    Hi, I am trying to use the ObjectListField but spin in many questions.

    I would like to than the selected row to be a different color, instead of the standard blue?  I would also like to know how you would add a listener?  When it is clicked on a line, I need to go to a new page, but I need to know which row was clicked.

    Any help or pointers would be much appreciated!

    After you set the background color, call clear() on the ground, before you paint the text.

    This will clear the context in which the current background color.

  • Background image for the ObjectListField

    Hey all:

    I am trying to use a background image on a custom ObjectListField. The image is for each line, and in the method of substitution of drawListRow, I had graphics.drawBitmap (...). However, only the first line in the area is drawn, and him still ignored the code. So I was wondering if there is a way to make the background of the line drawn for each line. Why graphics.drawBitmap in drawListRow affects only the first line?

    Any help is appreciated, thanks in advance!

    Looking at the signature of drawListRow:

    drawListRow (ListField listField, graphics card graphics, int index, int y, int width)

    I suspect that you do not use this setting are in your call drawBitmap.  If you use this call:

    drawBitmap(int x, int y, int width, int height, Bitmap bitmap, int left, int top)

    Make sure you spend the fourth parameter (is) of drawListRow as the second parameter (y) drawBitmap.

  • Weird problem in the ObjectListField

    Hi all:

    I knew a strange bug when try the BlackBerry 9000 "BOLD" Simulator. I had a custom class that extends the ObjectListField, and I wrote my own method of drawListRow (...). And since the data that I display comes in a vector, to initiate the Object [] need to do the ObjectListField to know how many items to draw, I use the following to the constructor:

    public CustomObjectListField(Vector data) {
            this.set(new String[data.size()]);
    }
    

    This code works perfectly well in the BB 8330 Simulator, which I use all along. The number of lines drawn is always correct, and no problems at all. However when I went to the BB 9000 "BOLD" Simulator today, the same code gave me a NullPointerException. I tried a few fixes, and worked the following:

    public CustomObjectListField(Vector data) {
            String[] size = {"1", "2", ... };
            this.set(size);
    }
    

    Basically, manually, statically instantiating a table String works. But obviously I can't predict the exact number of lines to draw each time, so this isn't a permanent solution. I was wondering why the first Builder worked in the Simulator 8330 but fails in the "BOLD" 9000 Simulator. RIM did not alter the way the tables are instantiated in the new version of their OS?

    Advice and suggestions are welcome. Thanks to all in advance.

    you are aware of your first construction creating an empty array?

    You can use Vector copyInto (Object [] anArray) to complete the table.

Maybe you are looking for