ListView question

I have a question about listview.

I download an RSS feed to a Web site that has several page in a listview, but I can only download a page at a time, so I was wondering if it was possible for the listview detect that I get at the end of the list, which is 15, then preload the second page online. And that as smoothly as possible.

Thank you very much for the help.

UPDATE:

I just saw that there was a ScrollPosition I could read: https://developer.blackberry.com/cascades/reference/bb__cascades__scrollposition.html

but I wonder about how to make the transition between the guy ending to the first page and the loading on the other, then the third ect... in listview

The solution is in my first answer

1. use a ListScrollStateHandler and connect to the signal atEnd. When the signal is received the user is at the end of the list - so load your json

2. use the datamodel personalized approach. When listview calls your function of DataModel::data() with a row that represents the end of the list, you know that the user did scroll down - so load your additional data, if this is true

Tags: BlackBerry Developers

Similar Questions

  • Load more at end of ListView

    I have a list view containing a lot of tweets. Looking through the asynchronous data providing the tutorial, it suggests a little game, then several charges, then a huge list of items. Because I am pulling Twitter, I'm not exactly making a huge tweets ever. Instead, I would rather load a different set of tweets (say, 50) whenever the user presses the end of the list view.

    Any advice on how I can achieve this? I would be very happy.

    This thread may help:

    http://supportforums.BlackBerry.com/T5/Cascades-development/ListView-question/m-p/2103203#M11906

  • Question on logic programming behind the the Twitter app to display secondary listviews

    Hey guys,.

    I tried to find how I would implement the Twitter app drag function where you're displaying the main power and can slide to the right to view a list of food trends.  At first I thought maybe create a Listview with two ListItemComponents and then adding a listview inside each with my data but I have problems getting whatever it IS displayed.  I feel like maybe I'm overloading it?

    Ideas or comments on maybe an easier way to do this.  I currently have a little a segmented control that replaces the listview data source and it works, but I think this new way would look nicer and more intuitive.

    I use ListView with layout LeftToRight and SingleItem flick and works fine

  • ListView raises the Question

    Hi all, I have a ListView with a XMLDataModel in it.

    How to retrieve data from the specific index which was clicked?

    Thank you...

    First of all, connect signal triggered (QVariantList) of the listview to a corresponding slot. You should be able to access the data in the index selected by using a feature similar to this slot:

    void MyClass::onListItemTriggered(QVariantList indexPath) {
        XmlDataModel* model = (XmlDataModel*)myListView->dataModel();
        QVariant myData = model->data(indexPath);
    }
    

    Where myData is millet resulting for this index pulled from the data model.

  • How to detect when ListView recycles an ImageView?

    I have a ListView with items ~ 600 in a 4-wide grid. Each element is a WebImageView (inherits from ImageView, slightly modified from code kindly provided here) over a label.

    Everything works spot - we (and performance is awesome) except for one glaring problem: when I sometimes momentarily the ImageView ListView displays scrolling scrolls the erroneous image of an item that was previously on. Sometimes it moves even between two prior images before displaying the right pair. These problems are happening because applications for network WebImageView queues upward because the visible element has been recycled once or even twice.

    What I need to solve this problem is to know when the WebImageView has been recycled by ListView in order to disconnect the network signals and erase the old image. I can't find how to do this.

    So I have a "fix" that is more than a workaround. In the WebImageView, I added a member variable:

    int m_iCurrentRequestIndex;

    Whenever WebImageView has applied for a network, I add m_iCurrentRequestIndex as an attribute of the QNetworkRequest and then increment.

    When I receive the response from the network, I check if the value of attraibute for example a_reply-> request (.attribute (...)) and throw the answer if it is not the last.

    Not a very good solution because it is always that which allows network support needless to proceed and just throw the results, but at least it works. But if anyone can answer the question in the original post, I who brand as the solution because it will allow for better efficiency. I want to know a signal or something available at WebImageView that is called when ListView is recycled as:

    WebImageView::onRecycled()
    {
        // close() and disconnect() current QNetworkRequest().
    }
    
  • To reorder ListView problem

    Hello

    10.3, reorganize the listview items is now possible via the RearrangeHandler class (https://developer.blackberry.com/native/reference/cascades/bb__cascades__rearrangehandler.html)

    I noticed during the implementation of this class that rearranging works only when the elements below are trained upward. When the elements at the top of the page it is slipped down the list, none of the signals (started, completed, updated, abandoned) don't are not fired. The user interface changes automatically isn't.

    Both the sample application or my implementation does not work when the elements above are trained more far.

    Can a BlackBerry person take a look at this? Thanks in advance.

    I tested on the official bone on the passport and classic version.

    I tried this sample and I see the same behavior that you are.  I sent the question to our development team to resolve.

    10.3.1 signals are fired, but you can not yet move items down.

  • How can I place a listview in a listview?

    Hello everyone.

    I do an application on my website and I would like to have an area featured inside, but I found a big problem when I try to add the recommended area to the main Listview (where the post is loaded).

    It is an example of what he would like to see inside my application:

    So I want to spend the "Star box" and "Feeding zone" at the same time, when the user tries to scroll vertically.

    I tried to use a ScrollView but the priority of scrolling is in vertical listview and the recommended area does not scroll only when the vertical scroll listview is finished.

    Could someone give me a suggestion?

    See you soon!

    I don't think we have an example that does exactly what you want, but basically, you could create a CustomListItem contains inner ListView.  You would need a second source of data for inner ListView or have the first element of your main data source to be another source of data.

    The main ListView could choose the ListItem to display based on a type item in the data source main or you could rely on the position. forumThreadList.qml shows how you can override the itemType method to select the type of item (if it is not defined in the original data source).  This example also shows how to use a CustomListItem, but not one that contains a ListView.

    Here is another example that shows a part of the implementation.  It would have a horizontal ListView in all the ranks of the main list.  If you combine these two you should be able to get what you are looking for.  Let me know if you have any questions along the way.

    import bb.cascades 1.2
    
    // creates one page with a label
    Page {
        attachedObjects: [
            //ComponentDefinition doesn't work because DataModel doesn't extend BaseObject
            ArrayDataModel {
                id: dm2
            },
            ArrayDataModel {
                id: dm3
            }
        ]
        Container {
            ListView {
                dataModel: ArrayDataModel {
                    id: dm
                }
                listItemComponents: [
                    ListItemComponent {
                        Container {
                            layout: StackLayout {
                                orientation: LayoutOrientation.TopToBottom
                            }
                            ListView {
                                preferredHeight: 100
                                //Thankfully the QVariant is a DataModel, so this works :)
                                dataModel: ListItemData
                                layout: StackListLayout {
                                    orientation: LayoutOrientation.LeftToRight
                                }
                                listItemComponents: [
                                    ListItemComponent {
                                        Container {
                                            layout: StackLayout {
                                                orientation: LayoutOrientation.LeftToRight
                                            }
                                            Label{
                                                text: ListItemData +"\t|\t"
                                            }
                                        }
                                    }
                                ]
                            }
                            Divider {}
                        }
                    }
                ]
            }
        }
        onCreationCompleted: {
            dm2.append(["This is","another list","inside of","the first one"])
            dm3.append(["<( \" <) <( \" <) <( \" <)","(^\"^) (^\"^) (^\"^)","(> \" )> (> \" )> (> \" )>","(^\"^) (^\"^) (^\"^)","(> \" )><( \" )><( \" <)","(^\"^) (^\"^) (^\"^)","<( \" <) (>\"<) (> \" )>","(v' 'v) (v' 'v) (v' 'v)"])
    
            dm.append(dm2)
            dm.append(dm3)
        }
    }
    
  • [Explanation necessary] Clears the listview data and fill it again with new data

    Hello

    I correctly filled a listview in c ++, data analysed and does interesting things with it. However, I am drunk stumbling, unable to find a way delete and repopulate my display of the list...

    Question 1:

     

    1. How can after I insert data in the list view, I clear the list data and run again the same method (init) who populated the list view with the data in the first place?

    Here are the docs that I referenced and I don't understand how to implement the methods in my code.

    QList - clear() method

    https://developer.BlackBerry.com/Cascades/reference/QList.html#clear

    Using the data access Code, example
                              
    data_access/using_data_source

    GroupDataModel - Clear()

    https://developer.BlackBerry.com/Cascades/reference/bb__cascades__groupdatamodel.html#clear

    CODE

    Here is my code - filling of the display of the list of C++ and display of data in a ListView.

    MyApp.cpp

    MyApp::MyApp(bb::cascades::Application *app)
    : QObject(app){
        // create scene document from main.qml asset
            // set parent to created document to ensure it exists for the whole application lifetime
            QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(this);
    
                AbstractPane *root = qml->createRootObject();
                qml->setContextProperty("yoyo",this);
                //grab references
                list_view = root->findChild("listView");
    
                // set created root object as a scene
                app->setScene(root);
    
                mNetworkAccessManager = new QNetworkAccessManager(this);
                bool result = connect(mNetworkAccessManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(requestFinished(QNetworkReply*)));
    
                 Q_ASSERT(result);
                 Q_UNUSED(result);                 json = new QFile("data/file.json");
    }
    
    void MyApp::init(){
        QNetworkRequest request = QNetworkRequest();
         // i call some service here
         mNetworkAccessManager->get(request);
    }
    
    void MyApp::requestFinished(QNetworkReply *reply){
        qDebug() << reply->error();
        qDebug() << reply->errorString();
        if (reply->error() == QNetworkReply::NoError) {
            qDebug() << "No error";
    
                    QByteArray data = reply->readAll();
    
                    if (!json->open(QIODevice::ReadWrite)) {
                        qDebug() << "Failed to open file";
                        return;
                    }
                    json->write(data);
    
            bb::data::JsonDataAccess jda;
            QVariantMap results = jda.loadFromBuffer(data).toMap();
                    QVariantList lst = jda.loadFromBuffer(data).toList();
                GroupDataModel *m = new GroupDataModel();
                       m->insertList(lst);
                       m->setGrouping(ItemGrouping::None);
                       if(list_view) list_view->setDataModel(m);
    
        }else{
            showDialog("Boo",reply->errorString());
        }
    }
    

    MyApp.hpp

    // Tabbed pane project template
    #ifndef MyApp_HPP_
    #define MyApp_HPP_
    
    #include 
    #include 
    #include 
    #include 
    #include 
    #include 
    
    namespace bb {
    namespace cascades {
    class Application;
    }
    }
    namespace bb {
    namespace data {
    class Application;
    }
    }
    
    /*!
     * @brief Application pane object
     *
     *Use this object to create and init app UI, to create context objects, to register the new meta types etc.
     */
    class MyApp: public QObject {
    Q_OBJECT
    public:
        MyApp(bb::cascades::Application *app);
        virtual ~MyApp() {
        }
        Q_INVOKABLE
        void init();
    private slots:
        void requestFinished(QNetworkReply *reply);
    private:
        QNetworkAccessManager *mNetworkAccessManager;
        QNetworkRequest *request;
        QFile *json;
        bb::cascades::ListView *list_view;
    };
    
    #endif /* MyApp_HPP_ */
    

    hand. QML

    import bb.cascades 1.0
    
    Page{
    Container {
                            background: Color.White
                            ListView {
                                id: listView
                                preferredHeight: maxHeight
                                objectName: "listView"
                                listItemComponents: [
                                    ListItemComponent {
                                        type: "item"
                                        Container {
                                            Container {
                                                Label {
                                                    text: ListItemData.id
                                                }
                                            }
    
                                        }
                                    }
                                ]
                                onTriggered: {
                                    console.log("selected_index: " + indexPath)
                                }
                                horizontalAlignment: HorizontalAlignment.Center
                                verticalAlignment: VerticalAlignment.Center
                            }
    
    }
    }
    

    Question 2:

    How reference to the ListView object with the name "listView" in different parts of the MyApp.cpp file? Is there anything else I should add to the header file to make the accessible listView?

    Question 3:

    What happens when you call the clear() method? How the data model is affected? How the user interface is affected? What happens in memory?

    Question 4:

    How do you verify that the data in the list has been deleted so that you can go ahead and fills again with new data? What is the cheque that I perform?

    I would also like to know how you manage multiple views of lists and data sources in your applications. Best practices or ideas?

    Thank you

    I was able to clear the listview with the following code, if anyone is interested.

    listView.dataModel = null
    

    The dataModel must be set to "null".

  • ListView / DataModel crash

    Hello

    I'll have a consistent crash in my application and could not find a solution. Basically I have a GroupDataModel as a QProperty in my main class. Then, I have a page with three buttons. Each button creates and opens a page different qml. One of the qml pages contains a ListView that is connected to the above mentioned data model. The first time the page is opened there is no problem. Then when I go back (which causes the page to be destroyed) and re-enter the page, it crashes. No other pages are affected and can be opened infinite times. I know that it is GroupDataModel, because if I change the listview datamodel to point to a temp .xml file I open this page again for unlimited times. Here are a few pieces of code that I feel are important to this question:

    in class.hpp

    public :Q_PROPERTY(bb::cascades::GroupDataModel *expensesModel READ expensesModel CONSTANT);
    
    private :
    bb::cascades::GroupDataModel* expensesModel() const;
    bb::cascades::GroupDataModel* m_expensesModel;
    

    in class.cpp

    bb::cascades::GroupDataModel* ExpenseTracker::expensesModel() const {
        return m_expensesModel;
    }
    

    in the page containing the buttons:

    Button {
                            text: "Loans"
                            onClicked: {
                                app.updateDataModel("", "Loan");
                                var page =loanPage.createObject();
                                page.type = "Loan"
    
                                mainNavigationPane.push(page);
                            }
                            attachedObjects: ComponentDefinition {
                                id: loanPage
                                source: "Expenses_QML/ExpensePage.qml"
                            }
                        }
                        Button {
                            text: "Reports"
                            onClicked: {
                                var page = reportPage.createObject();
                                mainNavigationPane.push(page);
                            }
                            attachedObjects: ComponentDefinition {
                                id: reportPage
                                source: "Reports_QML/ReportPage.qml"
                            }
                        }
    

    reportPage can be opened permanently, only expensePage.

    In the navigation pane:

        onPopTransitionEnded: {
            console.log("got here");
            page.destroy();
        }
    

    In ExpensePage.qml (which cannot be opened once)

    ListView {
                onTriggered: {
                    var viewExpensePage = viewExpensePageDef.createObject();
                    viewExpensePage.expenseData = dataModel.data(indexPath);
                    mainNavigationPane.push(viewExpensePage)
                }
                layout: StackListLayout {
                }
                /* with only this changed page can be opened infinite times
                 * dataModel: XmlDataModel {
                 * source: "models/sheetmodel.xml"
                 * } */
                dataModel: app.expensesModel
                listItemComponents: [
                    ListItemComponent {
                        type: "item"
                        id: listItemComponent
                        ExpenseListItemView {
                            id: thumbListView
                        }
                    }
                ]
            }
    

    I absolutely need this page to be created and deleted everything being open/closed, because it is the key in my architecture. So I can't solve this problem the "cheating" way to not destroy the page and leaving always responsible. All suggestions are welcome! If more code is needed let me know and I'll add it.

    Thank you

    Gerry

    You cannot use the same datamodel on several lists, you try to do?

    In addition, when a page is destroyed, everything on the page gets destroyed, so when listview is destroyed, it removes also the datamodel, who so if you try and open the page again, you will be the datamodel of new listview to an address memory random with nothing there, it will crash.

  • Notify the ListView data in the model have changed

    Hello!

    I know this question has been asked several times, but I have yet to find anything satisfactory.

    I have a ListView, filled with a QListDataModel.

    After some time I update an element of the model. So far, the only way I found to the ListView so that this change is to delete the model and then reappend all elements. But the problem with this approach is that ListView Flash and scroll to the top of the page. Is there anything better to just say ListView that it should update the visible elements?

    Thank you

    Well, I just signal myself in the WRITE method and it works.

  • ListView - multiple selection works only for StandardListItem

    Hello

    In the meantime, this ListView object are less contraingnant to use; I modified my UI to work as an example of application of Battambang.

    But I have another question

    I use a GridListLayout (such as sample app stamp collector) and my ListItem is a container custom instead of StandardListItem.

    Unfortunately multiselect Manager works only with StandardListItem

    In my case, the context menu is empty!

    RIM is able to provide a sample of collector of stamps with GridListLayout? and multi select Manager / work context menu? and to highlight the points of stamps feature works in multi selection mode?

    Nicolas

    Indeed, the DeleteActionItem is not visible all in Multi Mode. I also tested is not serious if it is set with GridListLayout or not and even deleteAction.enabled of adjustment.

    I have raised a question of public affairs to do this, https://www.blackberry.com/jira/browse/BBTEN-173 so, please vote for it when you get a chance.

    See you soon,.

  • Fill ListView using the C++ model

    Hello

    Sorry to bother, I guess my question must be pretty basic, but I'm new to bb10 SDK,

    What I intend to do is to show in a listview items, I calculated in C++. (In C++, because the logic for calculating them was quite complex)

    There, in the QT doc, you have exactly what I dream of:

    https://Qt-project.org/doc/Qt-5.1/QtQuick/QtQuick-modelviewsdata-cppmodels.html

    Unfortunately, I have several questions:

    -ownership model, seems to exist. But I guess we use dataModel in our context, right?

    -J' I also need to get the declarative context of the QmlDocument which I think is correct.

    -the delegate property also doesn't seem to exist, but I understand that I must use instead ListItemComponents ( http://developer.blackberry.com/native/reference/cascades/bb__cascades__listitemcomponent.html)

    But I'm still confused on how I should provide the data for the list view.

    Now, when I expose my QList of DataObject, as described in the Doc of QT and which gives as data to the dataModel is told that he cannot "affect QDeclarativeListReference to bb::cascades:ataModel."

    So I guess I have to use a QListDataModel instead of use a Qlist <>, or?

    Well, any help in pointing me to the right documentation would be very appreciated!

    Thank you

    fill us our data model in c ++ as well.

    For this, we use a Q_INVOKABLE method that gets the listview as a parameter.

    The ListView itself is created in QML.

    ListView* listView = dynamic_cast(listViewParameter);
    GroupDataModel* model = dynamic_cast(listView->dataModel()); if (model) {        model->clear();    } else {        model = new GroupDataModel(QStringList() << "sortParameter");        model->setGrouping(ItemGrouping::ByFullValue);        listView->setDataModel(model);    }//calculate stuffmodel->insertList(stuff);
    
  • How get the number of items in the ListView inside QML?

    QML/JavaScript newbe question here please.

    Suppose I have .qml

    import bb.cascades 1.0
    
    NavigationPane {
        id: navigationPane
        Page {
    ...
            Container {
    ...
                  ListView {
                        id: listviewPlayers
    ...
    

    and I want to do something if ListView does contain all of the elements

        onCreationCompleted: {
            // this slot is called when declarative scene is created
            if (listviewPlayers.AllItems.count() == 0){
                // do something;
            }
    

    but when I run the present I get complain AllItems is not defined in this line:

     if (listviewPlayers.AllItems.count() == 0){
    

    What I doing wron? I can do the same thing in C++ without any problem.

    Thank you.

    Oh, this thing AllItems seems to be a 'Sentinel' or a magic value used in special cases, unrelated to this.

    I think that ListView manages all this, but defers everything to do with the pieces of data to the model, you don't have to go to the model for the data. ListView knows how VisualNodes (the components list item) he created at the time of the display on the screen, but also have to tell you the total number of elements in the model would simply duplicate work. (The reasoning behind this interpretant.)

  • How to show my listview QML this JSON webservice

    Hi all

    IM new developer for blackberry 10

    It's my first project of construction of a PSA

    I want to ask

    1. This is my JSON www.rws.rajaspot.com/rs_promoclient.php

    2. I want to do a listview in my QML using this JSON

    y at - it a code for this example, I tried to make the market http://stackoverflow.com/questions/18598886/how-to-use-json-webservice-in-blackberry-cascades and http://stackoverflow.com/questions/18638067/how-to-create-listview-for-json-parsing-in-blackberry-ca... but still get error

    Please help, thanks

    Did you add this line to your .pro file...

    LIBS +=-lbbdata

  • ListView &amp; heads

    Hello!

    I'm having some difficulty with the definition of the properties of the my ListView header.

    Here are some of my code QML:

    ListView {
                id: threadView
                objectName: "threadView"
    
                dataModel: GroupDataModel {
                    id: modelPost
                    sortingKeys: ["timestamp"]
                    grouping: ItemGrouping.ByFullValue
                }
    
                listItemComponents: [
    
                    ListItemComponent {
                        type: "header"
                        Header {
                            id: header
                            title: ListItemData.author
                            subtitle: ListItemData.timestamp
                        }
                    },
    
                    ListItemComponent {
                        type: "item"
    
                        PostRenderer {
                        }   
    
                    }
                ]
            }
    

    As you can see, what I want to do is to sort items by time stamp. But the legend must be something else: the author of the message.

    And with the current code, the question I have, is that the header shows nothing... so just the gray rectangle + the blue line. No text.

    Strangely (to me), I don't see a content in the header if I write something like this:

    Header {
          id: header
          title: ListItemData
          subtitle: ListItemData.timestamp
    }
    

    And then he does not care about the subtitle, view just the title, and the title will be the sort key: the time stamp.

    I'm not sure that, in the doc:

    - http://developer.blackberry.com/native/reference/cascades/bb__cascades__header.html

    - http://developer.blackberry.com/native/reference/cascades/bb__cascades__listitemcomponent.html

    It seems that we could do it like this. Could someone tell me what I'm missing?

    BTW, I also see in the doc that the listItemComponent sometimes have a type "listItem", but in my experience, if it's not only "item" I won't be able to choose what will be displayed in the points...

    Could you tell me why?

    Thank you!

    Hello!

    GroupDataModel groups elements, in this case of timestamp. In the header of the function data() (ListItemData in QML) returns a common timestamp for this group of items. So he has no fields such as .title etc, it is just a timestamp. The fields are available only for items.

    As there can be multiple elements in the model with a given timestamp, additional logic will be necessary to search for a specific item, for example, while reiterating the and find a first point with this timestamp.

    Regarding "itemType" and "element":

    GroupDataModel returns the type "header" for the headers and 'article' for items. This can be replaced by the implementation of the function GroupDataModel::itemType() or declaring a function JavaScript itemType() QML and returning a string different for some (or all) indexPaths. ListView uses a ListItemComponent with corresponding itemType.

Maybe you are looking for