custom list field

Hi, I work with list filed, I need to customize the field List, I'll explain a little more. I have this picture.

I get the list of applications installed with codemodule feeder and now I want to show that, in the list, as you can see in the picture.you above can see the lock in the dark peak, I need to customize this pic with onclick.
I mean when I click on any line I want to delete this pic of lock in the dark of that line clicked in the list filed
and when I click again on the same line I want to insert this pic of lock in the same row.
I think I need to call the drawListRow method in the onclick or sonething else? Please guide me
Here's the code I used

public final class MyScreen extends MainScreen {

    CustomListField myListView;

    public MyScreen() {

        Bitmap listThumb = Bitmap.getBitmapResource("icon.png");
        String listTitle="Headline";
        String listDesc = "Mobile news feeds";
        String listDesc2 = " ";
        final Bitmap navBar = Bitmap.getBitmapResource("lock.png");
        Vector v = new Vector();
        for(int i=0; i<30; i++){
            v.addElement(new ListRander(listThumb, listTitle, listDesc,listDesc2, navBar));
        }
        //v.addElement(new ListRander(listThumb, listTitle, listDesc,listDesc2, navBar));

        myListView = new CustomListField(v){

            protected boolean trackwheelClick (int status, int time) {

                Dialog.alert(" You have selected :" + getSelectedIndex());

                return super.trackwheelClick(status, time);
            }
        }
        ;
        add(myListView);   

    }
}
package mypackage;

import net.rim.device.api.system.Bitmap;

public class ListRander {

    private Bitmap listThumb= null;
    private Bitmap navBar = null;
    private String listTitle=null;
    private String listDesc= null;
    private String listDesc2= null;

    public ListRander(Bitmap listThumb,String listTitle, String listDesc, String listDesc2, Bitmap navBar) {
        this.listDesc = listDesc;
        this.listDesc2 = listDesc2;
        this.listThumb = listThumb;
        this.listTitle = listTitle;
        this.navBar = navBar;
    }
    public Bitmap getListThumb() {
        return listThumb;
    }
    public void setListThumb(Bitmap listThumb) {
        this.listThumb = listThumb;
    }
    public Bitmap getNavBar() {
        return navBar;
    }
    public void setNavBar(Bitmap navBar) {
        this.navBar = navBar;
    }
    public String getListTitle() {
        return listTitle;
    }
    public void setListTitle(String listTitle) {
        this.listTitle = listTitle;
    }
    public String getListDesc() {
        return listDesc;
    }
    public void setListDesc(String listDesc) {
        this.listDesc = listDesc;
    }
    public String getListDesc2() {
        return listDesc2;
    }
    public void setListDesc2(String listDesc2) {
        this.listDesc2 = listDesc2;
    }
}
package mypackage;

import java.util.Enumeration;
import java.util.Vector;

import net.rim.device.api.system.Bitmap;
import net.rim.device.api.ui.Color;
import net.rim.device.api.ui.Font;
import net.rim.device.api.ui.Graphics;
import net.rim.device.api.ui.XYRect;
import net.rim.device.api.ui.component.ListField;
import net.rim.device.api.ui.component.ListFieldCallback;

public class CustomListField extends ListField implements ListFieldCallback {

    private Vector _listData;
    private int _MAX_ROW_HEIGHT = 60;
    public CustomListField (Vector data) {

        _listData = data;
        setSize(_listData.size());
        setSearchable(true);
        setCallback(this);
        setRowHeight(_MAX_ROW_HEIGHT);

    }

    protected void drawFocus (Graphics graphics, boolean on) {

        XYRect rect = new XYRect();
        graphics.setGlobalAlpha(150);
        graphics.setColor(Color.BLUE);
        getFocusRect(rect);
        drawHighlightRegion(graphics,HIGHLIGHT_FOCUS,true,rect.x,rect.y,rect.width,rect.height);

    }

    public int moveFocus (int amount, int status, int time) {

        this.invalidate(this.getSelectedIndex());
        return super.moveFocus(amount, status, time);

    }

    public void onFocus (int direction) {

        super.onFocus(direction);

    }

    protected void onUnFocus () {

        this.invalidate(this.getSelectedIndex());

    }

    public void refresh () {

        this.getManager().invalidate();

    }

    public void drawListRow (ListField listField, Graphics graphics, int index, int y, int w) {

        ListRander listRander = (ListRander)_listData.elementAt(index);
        graphics.setGlobalAlpha(255);
        graphics.setFont(Font.getDefault().getFontFamily().getFont(Font.PLAIN, 24));
        final int margin =5;
        final Bitmap thumb= listRander.getListThumb();
        final String listHeading = listRander.getListTitle();
        final String listDesc= listRander.getListDesc();
        final String listDesc2= listRander.getListDesc2();
        final Bitmap nevBar = listRander.getNavBar();
        //list border
        graphics.setColor(Color.BLACK);
        graphics.drawRect(0, y, w, _MAX_ROW_HEIGHT);

        //thumbnail border & thumbnail image
        graphics.setColor(Color.BLACK);
        graphics.drawRoundRect(margin-2, y+margin-2,thumb.getWidth()+2, thumb.getHeight()+2, 5, 5);
        graphics.drawBitmap(margin, y+margin, thumb.getWidth(), thumb.getHeight(), thumb, 0, 0);

        //drawing texts
       // graphics.setFont(FontGroup.fontBold);
        graphics.drawText(listHeading, 2*margin+thumb.getWidth(), y+margin);
        graphics.setColor(Color.BLACK);

        // graphics.setFont(FontGroup.smallFont);
        graphics.drawText(listDesc, 2*margin+thumb.getWidth(), y+ margin+20);
        graphics.drawText(listDesc2, 2*margin+thumb.getWidth(), y+ margin+32);

        //draw navigation button
        final int navBarPosY = y+(_MAX_ROW_HEIGHT/2 - nevBar.getHeight()/2);
        final int navBarPosX = Graphics.getScreenWidth()- nevBar.getWidth()+ margin;
        graphics.drawBitmap(navBarPosX-10, navBarPosY, nevBar.getWidth(), nevBar.getHeight(), nevBar, 0 , 0);

    }

    public Object get(ListField listField, int index) {

        String rowString = (String) _listData.elementAt(index);
        return rowString;

    }

    public int indexOfList (ListField listField, String prefix, int start) {

        for (Enumeration e = _listData.elements(); e.hasMoreElements(); ) {

            String rowString = (String) e.nextElement();
            if (rowString.startsWith(prefix)) {

                return _listData.indexOf(rowString);

            }

        }

        return 0;

    }

    public int getPreferredWidth(ListField listField) {

        return 3 * listField.getRowHeight();

    }

}

When I click on the particular line of the list, lock on the right side image should disappear. When I click again on the same line in the list, it should appear again.
something as in this link
http://StackOverflow.com/questions/8222635/how-to-display-and-hide-an-image-in-list-on-clicking-on-i...

Tags: BlackBerry Developers

Similar Questions

  • view the json data in the custom list field

    Hi, I did analysis json and I created the custom list field. Now, I want to display only the data analyzed in my custom list field. I'll post my analyzed data from json and here is the code for my custom list field
    data analyzed.
    I have THREE channels of json and I want to show content tittle and date in the list filed. I'll post the screenshot of my list.

    JSONArray jsnarry = new JSONArray(responce);
                System.out.println("\n--length----- "+jsnarry.length());
                //System.out.println("....................................................=");
                for (int i = 0; i < jsnarry.length(); i++){
    
                    JSONArray inerarray = jsnarry.getJSONArray(i);
                        //System.out.println("\n-inerarray-values----- "+inerarray.getString(i1));
                        String TITTLE = inerarray.getString(1);
                        String CONTENT = inerarray.getString(2);
                        String DATE = inerarray.getString(3);
                                                           System.out.println("TITTLE= "+TITTLE);
                        System.out.println("CONTENT= "+CONTENT);
                        System.out.println("DATE= "+DATE);
    
    }
    

    output

    [0.0] --length----- 2
    [0.0]
    [0.0] -innerarray-length----- 6
    
    [0.0] TITTLE= BJP State President Sanjay Tandon's visit to Amita Shukla's Home
    [0.0] CONTENT=  BJP President Chandigarh Sanjay Tandon at Amita Shukla's Home
    [0.0] DATE= 2013-01-04
    [0.0] ................................................
    [0.0] TITTLE= Sanjay Tandon at mahasamadhi of Satya Shri Sai baba.
    [0.0] CONTENT= BJP Chandigarh President, Sanjay Tandon mahasmadhi of Sri Satya Sai Baba.(Andhra Pradesh)
    [0.0] DATE= 2013-01-13
    

    and my custom list field

           super(NO_VERTICAL_SCROLL);
    
             String TITTLE="TITTLE";
             String CONTENT = "CONTENT";
             String DATE = "DATE";
    
             v.addElement(new ListRander(listThumb, TITTLE, CONTENT,DATE, navBar));
    
             myListView = new CustomListField(v){
    
                 protected boolean navigationClick(int status, int time) {
                     //Dialog.alert(" time in milisec :" + time);
                     return true;
                 }
             };
    

    CustomListField.java

    public class CustomListField extends ListField implements ListFieldCallback {
    
        private Vector _listData;
        private int _MAX_ROW_HEIGHT = 100;
    
        public CustomListField (Vector data) {
    
            _listData = data;
            setSize(_listData.size());
            setSearchable(true);
            setCallback(this);
            setRowHeight(_MAX_ROW_HEIGHT);
    
        }
    
        public int moveFocus (int amount, int status, int time) {
    
            this.invalidate(this.getSelectedIndex());
            return super.moveFocus(amount, status, time);
    
        }
    
        public void onFocus (int direction) {
    
            super.onFocus(direction);
    
        }
    
        protected void onUnFocus () {
    
            this.invalidate(this.getSelectedIndex());
    
        }
    
        public void refresh () {
    
            this.getManager().invalidate();
    
        }
    
        public void drawListRow (ListField listField, Graphics graphics, int index, int y, int w) {
    
            ListRander listRander = (ListRander)_listData.elementAt(index);
            graphics.setGlobalAlpha(255);
            graphics.setFont(Font.getDefault().getFontFamily().getFont(Font.PLAIN, 24));
            final int margin =5;
    
            final Bitmap thumb= listRander.getListThumb();
            final String listHeading = listRander.getListTitle();
            final String listDesc= listRander.getListDesc();
            final String listDesc2= listRander.getListDesc2();
            final Bitmap nevBar = listRander.getNavBar();
    
            //list border
            graphics.setColor(Color.BLACK);
            graphics.drawRect(0, y, w, _MAX_ROW_HEIGHT);
    
            graphics.drawBitmap(margin, y+margin+10, thumb.getWidth(), thumb.getHeight(), thumb, 0, 0);
    
            graphics.drawText(listHeading, 3*margin+thumb.getWidth(), y+margin);
            graphics.setColor(Color.BLACK);
    
            graphics.drawText(listDesc, 3*margin+thumb.getWidth(), y+ margin+30);
            graphics.drawText(listDesc2, 3*margin+thumb.getWidth(), y+ margin+60);
    
        }
    
        public Object get(ListField listField, int index) {
    
            String rowString = (String) _listData.elementAt(index);
            return rowString;
    
        }
    
        public int indexOfList (ListField listField, String prefix, int start) {
    
            for (Enumeration e = _listData.elements(); e.hasMoreElements(); ) {
    
                String rowString = (String) e.nextElement();
                if (rowString.startsWith(prefix)) {
    
                    return _listData.indexOf(rowString);
    
                }
    
            }
    
            return 0;
    
        }
    
        public int getPreferredWidth(ListField listField) {
    
            return 3 * listField.getRowHeight();
    
        }
    
    }
    

    Listrander.Java

    public class ListRander {}

    private bitmap listThumb = null;
    incognito bar Bitmap = null;
    private String listTitle = null;
    private String listDesc = null;
    private String listDesc2 = null;

    public ListRander (Bitmap listThumb, String listTitle, String listDesc, String listDesc2, Bitmap navBar) {}
    this.listDesc = listDesc;
    this.listDesc2 = listDesc2;
    this.listThumb = listThumb;
    this.listTitle = listTitle;
    this.navBar = bar navigation;
    }
    public getListThumb() {Bitmap image
    Return listThumb;
    }
    {} public void setListThumb (listThumb Bitmap)
    this.listThumb = listThumb;
    }
    public getNavBar() {Bitmap image
    return the navigation bar;
    }
    {} public void setNavBar (navigation bar of the Bitmap)
    this.navBar = bar navigation;
    }
    public String getListTitle() {}
    Return listTitle;
    }
    {} public void setListTitle (String listTitle)
    this.listTitle = listTitle;
    }
    public String getListDesc() {}
    Return listDesc;
    }
    {} public void setListDesc (String listDesc)
    this.listDesc = listDesc;
    }
    public String getListDesc2() {}
    Return listDesc2;
    }
    public void setListDesc2 (String listDesc2) {}
    this.listDesc2 = listDesc2;
    }
    }

    You seem to have two problems here and are confusing them.  You must break the problem into two parts

    (1) extract the data from the entry and create the objects you want to display

    2) display in a list, a set of objects.

    Let's get the sorted first premiera.

    I will suggest what to do here, but in practice, you might actually think about this yourself as part of the design phase of your application.  You should do this, not me, because then you will have all the information available.  At the present time, I have just what you said, which is not much.  So maybe what I'm telling you is not correct for your application.  Only you can decide that.  And be blunt here, you should have decided this before you start coding.  Do you want you could lead down the wrong path.  You must think of your application as a home - as the architect must design all the rooms, and how they will be built, before you start building the House.  You do not, then we are building the rooms on the fly.  Who knows if they will be fit at home?

    In this case, I think you need to create an object that represents each of the elements in the internal array of new data.  call this object

    NewsItem

    This object will have attributes, such as its title, content, date, the linked image and so on, each of whom have will get and set methods.  While you treat each inner element fetch you the associated entry and update the object.

    When you have finished the inner loop of processing, you now have a complete

    NewsItem

    Object, so you will add it to a collection, an array of NewsItem objects, call this _newsItems.  You will create it at the beginning - you know how many entries it takes because it is the number of entries in your outdoor table.

    So before you start to deal with JSON, create your table and the 'index' value of 0.

    Once you have created your Newsitem, add this in the table to the position 'index' and increment "index".

    And once you have analyzed all the JSON, you will have a complete picture.  This is part 1 finished!

    And note in your drawListRow, you are given a clue - that is the index in your tables in _newsItems.  So you can easily find which entry to view and display it correctly.  But it is part 2 and is a separate issue.

  • Problem with custom VerticalFieldManager, custom list field Call Back

    I created a custom vertical field Manager and a custom list field. It works very well in JDE 6.0.But when I build the same code in JDE 4.5 it throws the error because the setExtent Sub protected method (int width, int jeight) that I used in my code is final in JDE 4.5.

    so I changed my sublayout custom implemented code in vertical field Manager method. Again, this works very well in JDE 6.0.When I have to generate in JDE 4.5 is not to throw any errors.but when I run my code

    the list field does not have focus.

    I added a text field and a list custom field to the Vertical Field Manager text field focus but custom list field does not receive the focus. And the confusing part is when I click on the arrow to the getSelectedIndex from the scope of the list is changing and when I print listfield is active or not is the wrong impression.

    What is bad code works fine in jde 6.0 but not in jde 4.5, please let me know what I need to do something.

    Me as the ListField focus, but is not in fact poster it seems.  Have you made a

    . getLeafFieldWithFocus()

    to see if indeed he has the focus?

    I think we will have to see the ListField code for help.

  • How can I add a custom list field button?

    I have a CustomListField... I need to add a column of buttons on each line in the list... .c a someone hel [p me with the sample code... or the idea...

    Thank you.

    in case it helps. what worked for me is...

    first of the first 2 labels in line-> FOCUSABLE

    line-> NON-FOCUS

    button FOCUSABLE

    Now I can perform different actions when it is clicked on label or click on the button.

    Thanks Peter

  • Custom with LostFocus list field problems

    Hello experts!

    I made a custom, list field when I draw the lines, I made a solution using a personalized reminder, well... I have a problem when the list field lost focus, because when I have a focus to the button my list have a last item carried.

    I want to erase,

    Any suggestions?

    Best regards, Rampelotti

    in the drawListRow() method adds the underside before the draw.

    if(graphics.isDrawingStyleSet(Graphics.DRAWSTYLE_FOCUS))
    
  • animation in the list field

    actually my question is related to my previous thread .i have created a field of list with custom images.
    My question http://supportforums.blackberry.com/t5/Java-Development/custom-list-field/m-p/2623111#M223562

    animation in a listfield wouldn't be something I think.
    If you want to do in any case you will need to adjust your drawListRow and call invalidate (rowindex) for each image.
    As you redraw the complete list instead of only the bitmap line, it is much more expensive, you will need to test if it works well enough.

  • custom bitmaps field not change image when click on

    I created a custom bitmap field and I change the image on the center of my field of custom bitmaps and unfocus

    but when I implement the method of navigation click to change the image when you click on this image does not change...

    my custom bitmap field filed only to focus or unfocus on the image does not change my field of custom bitmaps.

    Bitmap onfocus = Bitmap.getBitmapResource("111.png");
                    Bitmap onunfocus = Bitmap.getBitmapResource("666.png");
                    mybutton1 = new CustomBitmapField(0,"",onunfocus,onfocus,Field.FOCUSABLE){
                         protected boolean navigationClick(int status, int time) {
    
                             mybutton1.setBitmap(Bitmap.getBitmapResource("favu.png"));
    
                             return true;
    
                         }
    
                    };
    add(mybutton1);
    

    and my class of field customBitmap is

    public class CustomBitmapField extends BitmapField {
    
        Bitmap Unfocus_img, Focus_img, current_pic;
        int width;
        String text;
        Font font; 
    
        public CustomBitmapField(int width, String text, Bitmap onFocus, Bitmap onUnfocus, long style) {
            // TODO Auto-generated constructor stub
            super();
            Unfocus_img = onUnfocus;
            Focus_img = onFocus;
            current_pic = onFocus;
            this.text = text;
            this.width = width;
    
        }
        protected void layout(int width, int height)
        {
            setExtent(current_pic.getWidth(), current_pic.getHeight());
        }
        protected void paint(Graphics graphics)
        {
            /*try
            {
                    FontFamily fntFamily = FontFamily.forName("BBAlpha Sans");
                    font = fntFamily.getFont(Font.BOLD,14);
            }
            catch(Exception e)
            {
                font = Font.getDefault();
    
            }
            graphics.setFont(font);
            graphics.setColor(Color.WHITE); */
            graphics.drawBitmap(0, 0, current_pic.getWidth(), current_pic.getHeight(), current_pic, 0, 0);
    
            //graphics.drawText(text, width, 7);
        }
        protected void onFocus(int direction)
        {
            super.onFocus(direction);
            current_pic = Unfocus_img;
    
            this.invalidate();
        }
      protected void drawFocus(Graphics graphics, boolean on)
      {
    
        }
        protected void onUnfocus()
        {
            super.onUnfocus();
            current_pic = Focus_img;
            invalidate();
        }
        public boolean isFocusable() {
            return true;
        }
        protected boolean navigationClick(int status, int time) {
    
            fieldChangeNotify(0);
            return true;
        }
    
    }
    

    When you debug this code, which of your methods of navigationClick, is actually used?

    When you expect the bitmap change, the code should lead object so that to happen.  Paint running?  This is the correct Bitmap painting?

    If you answer these questions, I think that you figure to yourself what is the problem.

    While you're there, you can also watch the following Threads that you have started or contributed to.  Can you solve or continue to contribute to these?

    http://supportforums.BlackBerry.com/T5/Java-development/gif-animation-not-displaying-properlly/m-p/2...

    http://supportforums.BlackBerry.com/T5/Java-development/timepicker-issue/m-p/2387819

    http://supportforums.BlackBerry.com/T5/Java-development/ListField-focus-color-problem/m-p/2407881#m2...

  • Accessing the context property of main.qml to a custom list in a file item separate qml

    Hi all

    Sorry if this is already covered somewhere.

    I currently have an application with a list view in my main.qml.  I put a context property for my class app c ++ to be "app" in my main.qml.  My list uses a custom list item that is defined in a file separate qml.  The custom list item has a popup menu.  In this context menu, I want to call Q_INVOKABLE functions that are part of my class from the main application in C++.  What is the best way to be able to do?  Should I just set the context property on my file qml of list item custom like I do with my main.qml or is there a better way?

    Thank you

    I think that this has been repeated several times, but as it is not really intuitive:
    a listitemcomponent lies in a different context, it cannot access the context property of the qml file.
    You can use the reference to the listview to reach outside, see https://developer.blackberry.com/cascades/reference/bb__cascades__listview.html ListItem.view

  • Slider custom text field (Cap) does not appear

    All;

    I created a custom text field based on the standard text field, changes work fine (really just a custom height and width and a border).  The problem is the method of painting which seems to remove the cap of the field when it gets the focus.  To be clear the carret never shown at all.

    public class CustomText extends TextField //cutom text field width
    {
        //Custom Height and Width in Pixels
        final static int textwidth=125;
        final static int textheight=25;
    
         CustomText()
         {
         super(); // Call the default constructor    
    
         //Border for text fields
         XYEdges padding = new XYEdges(5, 5, 5, 5); //space between box and border
         Border theborder = BorderFactory.createSimpleBorder(padding, Border.STYLE_SOLID);
    
         //Assign the border to the object
         this.setBorder(theborder);
         }
    
         public void onFocus( int direction )
         {
            super.onFocus( direction ); //invoke parent procedure
            invalidate(); //mark for redraw
         }
    
         public void onUnfocus()
         {
        super.onUnfocus(); //invoke parent procedure
        invalidate(); //mark for redraw
         }
    
         //Override the layout with the custom Width and Height
         protected void layout(int width, int height)
         {
            super.layout(textwidth,textheight);
            setExtent(textwidth,textheight);
    
         }      
    
        //Override the display message such that no message is displayed when the field is full
        protected void displayFieldFullMessage()
        {
        }
    
        //Override the default paint method to call the super class constructor and then assign the border
        protected void paint(Graphics graphics)
        {
           // int prevColor = graphics.getColor(); //Save Previous Color
            graphics.setBackgroundColor(Color.LIGHTGRAY); // Set to Gray
            graphics.clear(); // Clear for redraw
            super.paint(graphics); //Force Redraw of Object
          //  graphics.setColor(prevColor); //restore for cursor paint
    
        }
    
    };
    

    In the paint in the first and last method lines that are commented out were a soloution that I tried after reading on this subject.  Something along the lines of the restoration of the default color, but unfortunately without success.   Any ideas would be more useful

    Thank you!

    Quick thoughts:

    (a) to remove the requirement to substitute paint by setting the background a Color.LIGHTGRAY using the base class

    (b) you put on the field by using this:

    Super.Layout (TextWidth, TextHeight);

    If you then do the following:

    setExtent (textwidth, textheight);

    you are likely to confuse the field.  If you still want to use the entire height and use the full width and then try to deal with it in the Style, that is, replace this:

    Super(); Call the default constructor

    with this

    Super(TextField.USE_ALL_HEIGHT |) TextField.USE_ALL_WIDTH); Call the default constructor

    (c) why you override onFocus and onUnfocus?  I would like to delete these if you do not have anything specific to these methods.

    Make these changes, and you'll have a more simple TextField.  See if these changes will solve the problem of the caret too.

  • Question of width custom list.

    listItemComponents: [
                        ListItemComponent {
                            type: "item"
                            Container {
                                leftMargin: 5.0
                                topMargin: 5.0
                                layout: StackLayout {
                                    orientation: LayoutOrientation.TopToBottom
                                }
                                horizontalAlignment: HorizontalAlignment.Fill
                                Container {
                                    layout: StackLayout {
                                        orientation: LayoutOrientation.LeftToRight
                                    }
                                    horizontalAlignment: HorizontalAlignment.Fill
                                    Label {
                                        text: ListItemData.agencyName
    
                                        // Apply a text style to create a title-sized font
                                        // with normal weight
                                        multiline: true
                                        horizontalAlignment: HorizontalAlignment.Fill
                                        textStyle {
                                            base: SystemDefaults.TextStyles.TitleText
                                            fontWeight: FontWeight.Normal
                                        }
                                    }
                                    ImageView {
                                        imageSource: ListItemData.statusIcon
                                        verticalAlignment: VerticalAlignment.Center
                                        horizontalAlignment: HorizontalAlignment.Right
                                        preferredWidth: 32.0
                                    }
                                }
                                ProgressIndicator {
                                    fromValue: 100
                                    toValue: 0
                                    value: 50
                                    verticalAlignment: VerticalAlignment.Center
                                    horizontalAlignment: HorizontalAlignment.Left
                                }
                            }
                        }
                    ]
    

    Here, I have a custom list box. With a label on the left, a picture/icon on the right and a progress bar as to each item in the list.

    The problem is, I can't get the icon/image aligned right, it follows right after the text.

    That is to say.

    | This is a test X |

    | ------------------------------- |

    what I want

    | This is a test X |

    | ------------------------------- |

    Maybe my layout, I tried to add the horizontal fill everywhere, no change.

    You can fill a container with the background color to make sure that the external container takes the entire available width.

    If it doesn't, try setting preferredWidth (Infinity)

    HorizontalAlignment.Right won't work in LeftToRight in cause of a bug.

    There are several workarounds:

    -Use DockLayout. This is not very practical because can overlap, but for short strings (menus, etc), it can work. Here is an example in C++:

    http://supportforums.BlackBerry.com/T5/Cascades-development/list-item-image-size/m-p/2064721#M9602

    -Insert an empty container with .spaceQuota (1) between the left and right elements. Divide the right margin of the element left and the left margin of the right item in two (because the average container won't let not their margins overlap).

    PS Fill does not seem to work for StackLayout. Use rather preferredWidth/Height (Infinity).

  • Custom list item changes when you click

    I'm having a strange problem.

    When my list of messages is filled first, she checks a property in the json data to see if the message is 'read' or 'unread '. If it is "no read", it will be a different color than those who are already "read" to indicate to the user.

    It works very well, however I added an action context to the list, and when this action is triggered, I'm changing the message "unread". If the color of the list item to change. This works.

    However, after I changed the color of a single item in the listwhen I do scroll down and down, many elements change color. I think it has to do with the rendering of the list of recycling.

    This behavior does not occur after that list first initializes. Regardless of the colors have been queued to initialize their place. Only after that I have an amendment to one of the elements in the list, things go crazy when I scroll. I hope I'm being clear.

    How can I stop this from happening?  This is the code that changes the color of the label in my custom list item.

     listItemComponents: [
                                ListItemComponent {
                                    MessageListItem {
                                        id: messagesListItem
                                        contextActions: ActionSet {
                                            ActionItem {
                                                title: "Mark Unread"
                                                onTriggered: {
                                                    if (messagesListItem.isNew == false) {
                                                        var selectedItem = ListItemData;
                                                        messagesListItem.isNew = true; //property of list item is changed to unread
                                                    }
                                                }
                                            }
                                        }
    

    And inside the MessageListItem.qml

    property bool isNew: ListItemData.data.new
    
       onIsNewChanged: {
            if (isNew == true) {
                subjectLabel.textStyle.color = Color.create("#FF4500");
            } else {
                subjectLabel.textStyle.color = Color.create("#000000");
            }
        }
    

    Please let me know if you have any questions, any help or suggestion is appreciated. Thank you!

    Hello!

    I think that it doesn't because you are not changing 'new' dataModel element variable. In addition, assigning directly control isNew breaks property DataModel is bound to it.

    It should work if you change the dataModel instead.

    An important point to note, however, that it is not possible to change the individual variables of dataModel point. You need to replace the entire item. The code example for GroupDataModel: (not tested, so may require tweaks, tell me please if you need help in getting this work):

    onTriggered: {
      var selectedItem = ListItemData  // get a copy of dataModel's item
      selectedItem.new = !selectedItem.new  // modify it's property
      messagesListItem.ListItem.view.dataModel.updateItem(indexPath, selectedItem) // update the model
    }
    

    For ArrayDataModel, the function is named differently.

    In addition, this line seems suspicious:

    property bool isNew: ListItemData.data.new
    

    Probably, it should be replaced by this one:

    property bool isNew: ListItemData.new
    
  • Drop-down list field

    Hi friends,

    In my application from the drop-down list field that I used "ObjectChoiceField" it works but it does not feel like a drop-down list field

    How can I do?

    by the look, he must feel like a drop-down list field?

    Thanks in advance

    I've seen this done before overriding the method object of the ObjectChoiceField to use drawBitmap. In this way paint you a picture on the right of the field (such as the traditional arrow pointing down). You can also use drawRect to draw a rectangle around the whole thing make it look like more traditional.

  • Handle to the line on custom list

    I use the code in this page to display a custom list. The problem I have now is I want to handle each line onFocus event in the list to change its background color. No idea how to do?

    Hello

    You encounter method DrawListRow that you define the color as below

     public void drawListRow(ListField listField, Graphics g, int index, int y,
                int width)
        {
            if (g.isDrawingStyleSet(Graphics.DRAWSTYLE_FOCUS))
            {
                g.setColor(Color.RED);
            } else
            {
                g.setColor(Color.BLUE);
            }
    // then draw rect
    
                    g.drawRect(0, y, width, 80);
    //draw text in list
                    g.drawText("Blackberry", 90, y + 9);
             }
    

    ----------------------------------------------------------
    feel free to press the congratulations on the left side to thank the user who has helped you.
    Please mark as resolved messages if you found a solution.

  • Custom edit field - not drawing while typing of the text

    I created a custom edit field (code below), but there is no slider or text drawn while typing.

    The text appears if you click another field on the screen, but not while typing. I guess it has something to do with my method of painting, but I don't know?

    Tips for making more effective methos painting would be a bonus!

    Thank you!

    import net.rim.device.api.system.Display;
    import net.rim.device.api.ui.Font;
    import net.rim.device.api.ui.FontFamily;
    import net.rim.device.api.ui.Graphics;
    import net.rim.device.api.ui.component.EditField;
    
    public class CustomTextField2 extends EditField {
    
        private int fieldWidth;
        private int fieldHeight;
        private int button_colour = 0xF9F9F9;
        private int text_colour = 0x666666;
        private int border_color = 0xCCCCCC;
        private Graphics graphics = null;
        public CustomTextField2(long arg0) {
            super(arg0);
            fieldWidth = Display.getWidth()-100;
            //int off = 8;
            FontFamily fFam = null;
    
            try {
                fFam = FontFamily.forName("SomeFontHere");
            }
            catch (ClassNotFoundException e) {
                e.printStackTrace();
            }  
    
            Font font = fFam.getFont(Font.PLAIN, 20);
    
            Font defaultFont = font;
            int off = 8;
            fieldHeight = defaultFont.getHeight() + off + 10;
            this.setPadding(5, 20, 5, 20);  }
    
        protected void paint(Graphics graphics) {
    
            graphics.setColor(button_colour);
            graphics.fillRect(0, 0, fieldWidth, fieldHeight);
            graphics.setColor(border_color);
            graphics.drawRect(0, 0, fieldWidth, fieldHeight);
            graphics.setColor(text_colour);
            graphics.drawText(this.getText(),20,10/2);               super.paint(this.graphics);
        }
    
        protected void onFocus(int direction) {
    
            button_colour = 0xF9F9F9;
            text_colour = 0x666666;
            border_color = 0x3598CC;
            this.invalidate();
        }
    
        protected void onUnfocus() {
    
            button_colour = 0xF9F9F9;
            text_colour = 0x666666;
            border_color = 0xCCCCCC;
            this.invalidate();
        }
    
        protected void drawFocus(Graphics graphics, boolean on) {
    
              super.drawFocus(graphics, on);
        }
    
        protected void fieldChangeNotify(int context)
        {
            try {
    
            this.getChangeListener().fieldChanged(this, context);
    
            }
            catch (Exception e){
    
            }
        }
    
        public int getPreferredHeight() {
    
            return fieldHeight;
        }
    
        public int getPreferredWidth() {
    
            return fieldWidth;
        }
    
        protected void layout(int arg0, int arg1) {
    
            setExtent(getPreferredWidth(), getPreferredHeight());
        }
    }
    

    I just posted a code in another thread - he does most, if not all, of what you want. Take a look:

    Custom elegant EditField (textbox)

  • Custom text field

    I want to implement a custom text field that displays its label on the leading edge of a line and its part editable on the TRAILING edge of the same way like a ChoiceField. Is there a documentation available to achieve this (maybe it's to say-sample code)? Or even if I could see the source code for ChoiceField. I develop for a Blackberry Pearl 8110 with 4.3.

    I ended up solve this using managers of horizontal inside vertical management. I have to use a label field for the edit field that accompanies it. When lines are added, I followed is the width of the new label. Then in sublayout to align the edit fields according to the maximum width more stored a Variant. Could not align all the way to the right.

    import net.rim.device.api.ui.*;
    import net.rim.device.api.ui.container.*;
    import net.rim.device.api.ui.component.*;
    import net.rim.device.api.ui.text.*;
    
    public class MyLayoutManager extends VerticalFieldManager {
        protected int maxw;
        protected Font font;
        protected int font_height;
        private int size;
    
        public MyLayoutManager() {
            super(Field.USE_ALL_WIDTH);
            this.maxw = 0;
            this.font = Font.getDefault().derive(Font.PLAIN, 12);
            this.font_height = this.font.getHeight();
            this.size = 0;
        }
    
        public void addLine(String label, int initial) {
            MyEditField mef = new MyEditField(label, initial);
            int label_width = this.font.getAdvance(label);
            this.maxw = Math.max(label_width, this.maxw);
            this.add(mef);
            this.size++;
        }
    
        public int getPreferredHeight() {
            return this.size * this.font_height;
        }
    
        public int getPreferredWidth() {
            return 240;
        }
    
        protected void sublayout(int maxwidth, int maxheight) {
            int y = 0;
            for (int i = 0; i < this.size; i++) {
                Field f = this.getField(i);
                this.setPositionChild(f, 0, y);
                this.layoutChild(f, 240, this.getPreferredHeight());
                y += this.font_height;
            }
            this.setExtent(240, this.getPreferredHeight());
        }
    
        protected class MyEditField extends HorizontalFieldManager {
            private LabelField the_label;
            private JunkField the_value;
    
            public MyEditField(String label, int initial) {
                super(Field.USE_ALL_WIDTH);
                this.the_label = new LabelField(label);
                this.the_label.setFont(font);
                this.the_value = new JunkField(initial + "");
                this.the_value.setFont(font);
                this.add(this.the_label);
                this.add(this.the_value);
            }
    
            public int getPreferredHeight() {
                return font_height;
            }
    
            public int getPreferredWidth() {
                return 240;
            }
    
            protected void sublayout(int maxwidth, int maxheight) {
                Field f = this.getField(0);
                this.setPositionChild(f, 0, 0);
                this.layoutChild(f, maxwidth, maxheight);
                f = this.getField(1);
                this.setPositionChild(f, maxw + 20, 0);
                this.layoutChild(f, maxwidth, maxheight);
                this.setExtent(maxwidth, font_height);
            }
    
            private class JunkField extends EditField {
                private boolean firstFocus;
    
                public JunkField(String deflt) {
                    super(Field.EDITABLE | Field.FOCUSABLE);
                    this.setText(deflt);
                    this.setFilter(new NumericTextFilter(TextFilter.NUMERIC));
                    this.firstFocus = false;
                }
    
                protected void onFocus(int direction) {
                    this.firstFocus = true;
                }
    
                protected boolean keyChar(char key, int status, int time) {
                    if (this.firstFocus) {
                        this.setText("");
                        this.firstFocus = false;
                    }
                    return super.keyChar(key, status, time);
                }
            }
    
        }
    }
    

Maybe you are looking for

  • How can I remove Quick Search Bar 4.5 Add on

    I tried to add the search engine different what you ask because I had to reset my computer to a restore point prior and found this add through your research tools page. now I want to remove it but I can't find it in programs and features.

  • IMAQ create and SubVIs

    Hello! I am video capture with IMAQ. I have a hand program and a Subvi, which made the acquisition. When I use the Create.vi IMAQ to allocate say 5000 photos in the Subvi runns all fine but whenever I call the Subvi there is a delay until all images

  • How to select the photos I want to import?

    De : John Watson Message: I have a card from camera with 120 picture about it. I want to only three import images in Windows Vista Photo Gallery.How can I select three images only of import? I don't see any option to select only the pictures I want t

  • VISTA is unbootable

    From my previous post, my computer has problems freezing/locking up.  Got to the point where I completely reloaded OS of HD partitioned (HP).  Did chkdisk routines, recovery, run sfc/scannow, HP/PC doctor, and a clean boot with each other as possible

  • Use of data of blackBerry Smartphones

    Hi, I'm in a network using hw vodacom nd bis, I do the fins of the downloads are chargable. My Bill continues to go up.I had a knwowledge which is free internet BIS on my BB.9380