Unable to fill ListView with vector

I'm using a sample I got on the internet to create a listfield

that contains an image and the data contained in a vector.

Data are obtained from a JSON array that is created from a script php accessing a mysql database.

The problem is that the listfield poster not only any content, even if there are items in the table.

This is the code I use to get the JSON array data :

JSONArray items_array=job.getJSONArray("items");
                    for(int i=0;i

The code for the ListFieldCallback:

class MyListModel implements ListFieldCallback
       {

           private ListField _view;
           private int _defaultRowHeight=32;
           private int _defaultRowWidth=_defaultRowHeight;
           private int _txtImagePadding=5;
           private Bitmap _bitmap;
            private Vector _data;
           public MyListModel(ListField list,Vector data)
                 {
                     _view=new ListField();
                    _data=new Vector();
                     _data=MyScreen.data_vec;
                     _view=list;
                     list.setCallback(this);
                    // _view.setSize(_data.size());
                     _view.setRowHeight(_defaultRowHeight);
                     _bitmap=null;

                     //list.setSize(_data.size());                     

                     }

           public void drawListRow(ListField list,Graphics g,int index,int y,int w)
           {
               Items itemToDraw=(Items)this.get(list,index);
               String name=itemToDraw.getName();
               g.drawText(name,_defaultRowWidth+_txtImagePadding,y,DrawStyle.LEADING|DrawStyle.ELLIPSIS,w-_defaultRowWidth-_txtImagePadding);

               g.drawBitmap(0,y,_bitmap.getWidth(),_bitmap.getHeight(),_bitmap,0,0);

               }

The code for the method of success which must now fill listview:

public void success(final Vector listboys)
        { 

          UiApplication.getApplication().invokeLater(new Runnable()
          {public void run()
          {
             data_vec=new Vector();
          data_vec=listboys;
          Items it1=(Items)data_vec.elementAt(0);
          error("Vector Main Screen " +it1.getName());
                             final MyListField myListView=new MyListField();
      final  MyListModel myListModel=new MyListModel(myListView,data_vec);
     myListView.addToContextMenu(myListModel.getAddMenuItem(0,0));
    myListView.addToContextMenu(myListModel.getRemoveMenuItem(0,0));
    myListView.addToContextMenu(myListModel.getModifyMenuItem(0,0));
    myListView.addToContextMenu(myListModel.getEraseMenuItem(0,0));

    {
        Manager vfm=getMainManager();
        vfm.add(myListView);
        vfm.add(new SeparatorField(SeparatorField.LINE_HORIZONTAL));
        setTitle("List Demo Title");

        }

The listview is always empty. I don't see where data is passed to display. Whenever I call:

list.setSize(_data.size());

I always get a null pointer exception. How can I get the listview to display the data contained in the vector itemsholder. Thank you

using images in a listfield is not difficult, to improve that worked for you.

You can use drawBitmap to draw the image in the listfield.

Tags: BlackBerry Developers

Similar Questions

  • Using ListView with ArrayDataModel displays only the first element in each QVariantMap within the matrix

    I have this QML who have a ListView with datasource to a full ArrayDataModel from the CPP file for creationcompleted, I loop in the table to add the hour together to appear as a label on the page, what works. However, when I want to view these items in the list, it will display only the first element of the QVariantMap within the table, no error on the log of the device. Also, triggered more does not work, but when I click it, it will have a blue border surrounding it, but the onTriggered does not fire.

    Here is an excerpt of the CPP on the table fill

    This-> eventsModel = new ArrayDataModel();

    QVariantMap event;

    event ['EventName'] = "Event1";

    event ["EventHour"] = "00";

    event ["EventMinute"] = "01";

    event ["EventSecond"] = '02 ";

    QML-> setContextProperty ("eventsModel", it-> eventsModel);

    Here's the QML

    {Of container

    ID: eventListContainer

    {To ListView

    ID: eventList

    dataModel: eventsModel

    Use a ListItemComponent to customize the appearance of the list view

    listItemComponents:]

    {ListItemComponent}

    type: 'point '.

    {StandardListItem}

    Title: 'Event' + ListItemData.EventName;

    Description: "time:" + ListItemData.EventHour + ":" + ListItemData.EventMinute + ":" + ListItemData.EventSecond; "»

    }

    }

    ]

    onTriggered: {}

    var selectedEvent = dataModel.data (row);

    var eventDetailPage = eventDetailDefinition.createObject ();

    eventDetailPage.txtEventName.text = selectedEvent ['EventName'];

    eventDetailPage.pickEventTime.value = picker.dateFromTime(selectedEvent["EventHour"]+":"+selectedEvent["EventMinute"]+":"+selectedEvent["EventSecond"]);

    eventDetailPage.open ();

    }

    }

    Any help would be appreciated.

    Thank you.

    ListView determines ItemType of the element by calling the function itemType of the dataModel. By default, an ArrayDataModel returns an empty string for this call (see https://developer.blackberry.com/cascades/reference/bb__cascades__arraydatamodel.html).

    This leaves you with a few options:

    (1) If you have no header and all the elements are the same, you can make

    ListItemComponent {
         type: ""
         ...
    

    (2) If you have headers or different elements, you can extend ArrayDataModel and implement your own function of itemType

    (3) you can define a function of ItemType on your ListView in QML. Documentation:

    ListView called DataModel::itemType() for each item in order to know the type. QML, this can be overridden by declaring the itemType function (data, row) on the ListView element. ListView then call this function instead of the function DataModel.

    Here's how to create a list in QML which creates a header for all items on the high level and aStandardListItem for each item below the top level:

  • I have iOS 10 and I am still unable to make messages with animation effects. How can I solve this problem?

    I have iOS 10 and I am still unable to make messages with animation effects. How can I solve this problem?

    Without knowing what is happening when you try, it is difficult to recommend troubleshooting. However, one of the first steps is to ensure that you don't have to reduce the Motion activated in accessibility.

  • ProcessGPORegistryPolicy: Detected the error 87 when filling registry with settings in the file to archive temporary.

    I'm seeign as below errors in gpsvc.log and gpupdate/force fails with the error below.

    "Processing of Group Policy failed because of internal system error".

    RSOP appears in the confiuration computer, registry error, Unspecified.

    ProcessGPORegistryPolicy: Detected the error 87 when filling registry with settings in the file to archive temporary.

    SetRegistryValue: Could not open the key < software\policies\microsoft\windows\windowsupdate\au=""> 87

    Could you please help in investigating it?

    Concerning

    Murali

    Hello

    I suggest you to send your request in the TechNet forums.

    http://social.technet.Microsoft.com/forums/en/category/w7itpro

    http://social.technet.Microsoft.com/forums/en/categories

  • After the upgrade to the latest version of Windows Live Messenger, I am unable to video chat with one of my contacts.

    original title: error 0 x 81000430

    I've recently updated my computer to the new version of live messenger and now am unable to video chat with one of my contacts. She appears offline to me, even when it is on. We tried to remove and reinstall messenger, we made sure neither one of us was blocking the other, but to no avail. I can contact and chat with everyone except her, I get an error message 0 x 81000430. Should I remove the new version and reinstall the old one since it has worked well for years?

    Hello

    The question you have posted is related to Windows Live, and would be better suited in the Windows Live forum. Please visit the link below to find a community that will provide the support you want. http://windowslivehelp.com/

  • ListView with lines divided into two sections

    Hi guys,.

    How can I develop a listview with rows in two separate sections, as below:

    - - - - - - - -

    Section 1

    - - - - - -- -

    Line a1

    Line a2

    .

    .

    Line am

    - - - - - - - -

    Section 2

    - - - - - - - -

    Line b1

    Line b2

    .

    .

    Line bn

    use two separate fields

  • Local disk (q :)) appeared, unable to do something with it...

    Windows 7 32 bit

    Under the computer/hard disks, it shows 2 hard drives

    Tl1975657WOD (c :))

    Local disk (q :))

    I have nothing plugged in ports, sometimes I use an external hard drive that is identified as #@ & (@ (e :)))

    Here's my question: what (q) appeared all of a sudden, I can't move it, access, delete, open, copy, rename or format.

    I right click go to properties it shows as complete, used space: 0bytes free space: 0bytes, capacity: 0bytes

    I go to security, it says to continue you must be admin user with permission to view the properties of objects security: I'm Admin, I click on continue, under the current owner, it says: unable to display current owner.

    So, it's this new record Local (q) who does not have capacity, current owner, I am unable to do anything with this player. I realize there is no then what is it, where it comes, and HOW DO I REMOVE IT?

    I rebooted, basically all the things normal and advanced to remove, delete, access, appropriating and cannot do anything with it...

    I haven't installed any new programs or devices, I have anti virus and fire wall running, I get no warnings of all programs on it!

    I am very confused... Can someone help me out here?     Thank you

    Robert

    This disk is used by the click ' n Run Version of Office 2010.

    If you have installed Office 2010, which created and he needs.

  • Hi - I am trying to draw an irregular shape (series of straight lines) and fill it with the color... How can I do this?

    I need to draw a shape irregular, closed, which is a series of joined lines and fill it with the color, etc., I can only see square, polygon, etc...

    Any suggestions?

    You can set the polygon tool to 3 sides, or use the pen tool.

  • My collection of "All photos" fills upward with images that aren't mine... most of these pictures looks like Microsoft icons.  How can I get rid of these?

    My collection of "All photos" fills upward with images that aren't mine... most of them look like Microsoft icons.  How can I get rid of them and prevent any more?

    Right-click on one of the images icons Microsoft and select "Go to library folder." Check if you have imported inadvertently a system folder or documents. Check the folder in the library 'Files' pane and if it's a subfolder to navigate to the top-level folder. Make sure that it does not contain any image files you want inside LR by checking the names of all the subfolders. If in doubt always select menu library > "Show pictures in subfolders", then in grid mode through the images. Once confirmed you can 'remove' unwanted images from LR by doing a right click on the top-level folder and selecting 'delete '. The files will be deleted from LR, but not your hard drive.

  • Images to fill browser with multiple images?

    Hello

    Is it possible somehow to create an images to fill browser container and fill it with several small images than underlying when resizing with the large container anyway the browser window height or width changes.?

    Hard to explain but I mean, within the Muse, to create something like this site:

    http://www.etonshirts.com/fi/Eton-story/Eton-history

    All the small images resize when resizing the browser window, but yet is not an overview, because they have their own text box freak out.

    Is there a work around to create something similar like this in the Muse?

    Cheers, Jefunne.

    Reactive Adobe Muse CC 2015 is now online. Please install the update of CC > Apps.

    What's new: news summary

    Release notes: https://helpx.adobe.com/muse/release-note/adobe-muse-release-notes.html

    Delicate design:

    Adobe help Muse | Create responsive Web sites

    Adobe help Muse | Responsive web design in Adobe Muse

    Adobe help Muse | Migrate existing Adobe Muse Web sites to answer

    Tutorials

    To get started with Adobe Muse (replaces how to make a website with Adobe Muse (coffee of Katie)):

    - https://helpx.adobe.com/muse/how-to/create-responsive-website.html

    Create a sensitive webpage with Adobe Muse:

    - https://helpx.adobe.com/muse/how-to/responsive-web-design.html (more detailed features RWD of Muse demo)

    Thank you

    Sanjit

  • Do I need to use javascript to get a text field in a PDF Tue Fill form with / date of the current day?

    I have a form for booking appointments, and here the date field to fill automatically with

    today's date and print it. I put in the format of the text field 'Date' and when I place the cursor in the

    today's date date field, poster. It disappears as soon as I tab to the next field.

    This action does need a javascript script to fill and print today's date? If Yes, where can I find that?

    Or y at - it another way to fit the text field (not counting as the current date by typing) to get the current date?

    Thank you.

    Ali

    using iMac 2.93 GHz Intel Core 2 Duo 8 GB | OS Snow Leopard 10.6.8 | Acrobat 8 Pro

    See example Acrobat JavaScript by Chris Dahl. The script can be an action script open document level or page to insert the date when the PDF file is open or use as a print action to fill the date just before printing the form. And the formatting of the field is 'None' because JavaScript applies the formatting.

  • Unable to fill To_Date even as From_Date in simultaneous program

    Hi all

    I have a concurrent program in which I use the From_Date and To_Date parameters. The valueset that I use in both is FND_STANDARD_DATE.
    My requirement is I want that when the user enters the From_Date to To_Date parameter field should get automatically filled in with the same value. For this purpose in the To_date parameter, I used the Default_Type in the Segment and the Default_Value as P_FROM_DATE (From_date variable).

    But this does not work, when running, it gives the error APP-FND-00806.

    Can someone help me please for this. is there any other valueset that should be used or will I change the Default_Type.
    If anyone can provide me with guidance, it would be really useful.

    Kind regards
    Shruti

    Hello

    Try to set the from_date as low setting and the to_date setting as high (it is not necessary to define a default value) in the field of the beach, in the definition of the parameters. It will be useful.

    Kind regards.

  • is unable to scale a 3D vector length as you wish

    I try to view a vector 3D of a scene. I want the vector position, direction and length to vary with time. The home of the dmonstrates program it.  The position vector and the direction change as you wish, but the length does not change as you wish.  The problem may be clear, if you run the attached VI.  Basically, I create a vector oriented according to the Z axis.  With each time step, I change its length along Z, then translate it in the desired position, then turn it to the desired response.  The problem is that the cycles of component Z between 0 and 1, rather than the length of cycle between 0 and 1.

    I searched the forums for discussion of assistance, does not.

    I assumed that this situation occurs because the component most recently posted version of the vector z was being phased out, instead of scaling the vector of the component z of the INITIAL report, that points along the z axis.  That's why I tried to create 2 copies of the vector object.  A copy is the "variable" which is processed and displayed.  The other is kept not transformed.  At each stage of the stime, I copy that unprocessed to processed, and then transform.  This did not remedy the problem.  I tried to erase all the transformations at the end of each timestep - and this is the verion I my validation.  However, this does not have the problem.

    A solution I've seen for this problem is to create a new vector object during each time step, and then add it to the stage, and then resize it, translate and turn it.  Then, when it is displayed, the object is removed from the scene.  Then a new vector object is created for the next time step.  It seems mathematically inefficient and inelegant, and I'm worried about memory fills, since I would create a new object every 50 milliseconds.

    Two subVIs (DrawUnitArrow, DrawUnitAxes) are also attached.

    Thank you.

    In VI you posted, if you replace the "Set Rotation" with an 'object to turn' vi vi, I believe you get the desired behavior. (You probably also want to turn before translate you)

  • Filling ListView disorder

    Hello

    I have a problem inserting a QVariantList data in a ListView by using a GroupDataModel. The application works, but the list is empty. I confirmed that the QVariantList is not empty. I have been struggling with this for a while and you'd be grateful for any help.

    Since the constructor of the app:

    mDb = new databaseHandler();

    mQml = QmlDocument::create("asset:///main.qml");
    -setContextProperty expose QML as a C++ object variable
    {If (! mQml-> {hasErrors())}
    -> setContextProperty mQml ("app", this);
    mTimer = new QTimer (this);
    Connect (mTimer, SIGNAL (timeout ()), this, SLOT (update ()));

    mRoot = mQml-> createRootObject();
    loadData();
    Application::instance()-> setScene (mRoot);

    int i = 9;
    }
    on the other
    {
    QList error = mQml-> errors();
    }

    Sub App::loadData()
    {
    QString databaseName = "timetracker_test_data.db";
    mTimeEntries = mDb-> loadDataBase (databaseName);
    GroupDataModel * mDataModel = mRoot->findChild ("timeEntryModel");

    QVariantList sqlData.

    for (int count = 0; count)< mtimeentries.count();="" count="">
    {
    QVariantMap timeEntryMap;
    timeEntryMap ['description'] is mTimeEntries [count] .getDescription ();.
    int time = mTimeEntries [count] .getTotalTime ();

    timeEntryMap ['time' = intTimeToString (time);
    sqlData.append (timeEntryMap);
    mRoot-> setProperty ("currTimeText", mTimeEntries [count] .getDescription ());
    mDataModel-> insert (timeEntryMap);

    }

    mDataModel-> insertList (sqlData);
    }

    From main.qml:

    {To ListView
    ID: listContainer
    itemTextStyle variant of property: defaultBlackTextStyle
    dataModel: timeEntryModel

    listItemComponents:]
    {ListItemComponent}
    type: 'TimeEntry.
    {TimeEntry}
    }
    }
    ]
    attachedObjects:]
    A GroupDataModel is used for the presentation of the SQL data. The installation is made here
    with the exception of the actual population of the model, which is done in C++.
    {GroupDataModel}
    ID: timeEntryModel
    objectName: "timeEntryModel."
    }
    ]
    }

    and TimeEntry.qml:

    {Of container
    layout: {StackLayout}

    }
    {Label
    The title is related to the data of the models title attribute / recipemodel.xml.
    text: ListItemData.description;
    textStyle {}
    Base: SystemDefaults.TextStyles.TitleText
    color: Color.Black
    }
    }
    {Label
    The title is related to the data of the models title attribute / recipemodel.xml.
    text: ListItemData.time;
    rightMargin: 25.0
    leftMargin: 25.0
    layoutProperties: {StackLayoutProperties}

    }
    rotationZ: 0.0
    textStyle {}
    Base: SystemDefaults.TextStyles.TitleText
    color: Color.Black
    }
    }
    }

    Thanks for the replies on this one. Turns out I was diagnose the issue wrong all along. It turns out that my listview has been filled from the beginning, but a UI issue was causing my listview can be hidden by another component. (don't ask why I never checked this first) The nice thing about this 'non-issue', it is that I now know how the listview works both inside and outside that I tried all possible methods to solve this problem

    Gerry

  • Filling point with the body of the pl/sql function

    Hello

    I want to fill an item "Show as text (saves the State)" in contrast to the other 2 points.

    The source of my question is:
    -Only when the current...
    -Body of PL/SQL function
    -Term source:
    DECLARE
    v_diff NUMBER;
    BEGIN
    v_diff: =: P1_AUFWAND_TOTAL -: P1_AUFWAND_BERECHNET;
    Return v_diff;
    END;

    Now I get this error:

    ORA-06502: PL/SQL: taking oder Wertefehler: Fehler beim zu if indication Zahl von
    Error ERR-1904 unable to calculate the default item: type = body of the function...

    I tried to find the problem with the conversion to_number:
    v_diff: = to_number(':P1_AUFWAND_BERECHNET'); or
    v_diff: = to_number (': P1_AUFWAND_BERECHNET', '999G999D00');

    What's not here? It's as if I'm making a simple mistake...

    Thanks for any help,
    Roger

    If the following code does not work for you, then one of the two elements are not the numbers:

    DECLARE
       v_diff   NUMBER;
    BEGIN
       v_diff := TO_NUMBER (:p1_aufwand_total)
                 - TO_NUMBER (:p1_aufwand_berechnet);
       RETURN v_diff;
    EXCEPTION
       WHEN OTHERS
       THEN
          RETURN SQLERRM;
    END;
    

    Denes Kubicek
    -------------------------------------------------------------------
    http://deneskubicek.blogspot.com/
    http://www.Opal-consulting.de/training
    http://Apex.Oracle.com/pls/OTN/f?p=31517:1
    -------------------------------------------------------------------

Maybe you are looking for