Display the Dynamic list under tab screens using dataproviders

6 messages - 1733 views

Hi All,

 

I am trying to display the dyanmic list under Tabs screen using dataproviders. Thorugh KuixKaprice project i displayed the dynamic list on direct screen well. But whenever i called the tab items on the screen under each tabitem dynamic display not working means list was not displayed on the screen. Why this was not working i cant understand. please let me know the solution for this if Anybody knows......

 

Regards,
Suresh A

Do you use "dynamic" tabitems or "static" ? In other words, do you use the "rendrer" attribute in your tab folder or are your tabitems hard coded into your xml or java code ?

I used the static tabitems. and my tabitems are hard coded in xml. Only for list items display using the dataprovider. i used the list renderer .

I post my xml code here...

 

<screen cleanUpWhenRemoved="true">
   
   
   
    <tabfolder  >
       
        <tabitem style="layout:borderlayout" icon="call_img.PNG" label="Logs" id="tab1">
           
            <textfield style="layout:borderlayout;layout-data:bld(north);align:center;margin:2;border:0;bg-image:url(white_dialer.PNG);border-color:white;font-style:bold;font-size:large;min-size:20 10">
               
                09983866866
               
            </textfield>
           
            <container  style="layout:borderlayout;layout-data:bld(center)" >
                <scrollpane >
                    <list >
                        <_renderer >
                            <![CDATA[
            <listItem onfocus="contactfocus" style="layout:gridlayout(3,1)" onAction="show">
                <picture style="align:left">arrow-green.PNG</picture>
                <container style="layout:inlinelayout(false,fill)">
                    <text >@{name}</text>
                </container>
                               <picture >Mobimoovicon.PNG</picture>
            </listItem>
            ]]>
                        </_renderer>
                        <_items >@{calllogs}</_items>
                    </list>
                </scrollpane>
            </container>
           
         
        </tabitem>
       
        <tabitem style="layout:borderlayout" icon="contact_img.PNG" label= "Contacts" id="tab2">
           
            <container  style="layout:borderlayout;layout-data:bld(center)" >
                <scrollpane >
                    <list >
                        <_renderer >
                            <![CDATA[
            <listItem onfocus="contactfocus" style="layout:borderlayout" onAction="show">
               
                <container style="layout:inlinelayout(false,fill)">
                    <text >@{name}</text>
                </container>
                             
            </listItem>
            ]]>
                        </_renderer>
                        <_items >@{contacts}</_items>
                    </list>
                </scrollpane>
            </container>
           
           
           
          
        </tabitem>
        <tabitem style="layout:borderlayout" icon="chat_img.PNG" label="M2MUI" id="tab2">
          
            <container  style="layout:borderlayout;layout-data:bld(center)" >
                <scrollpane >
                    <list >
                        <_renderer >
                            <![CDATA[
            <listItem onfocus="contactfocus" style="layout:gridlayout(2,1)" onAction="show">
                 <picture>M2MUI.PNG</picture>
                <container style="layout:inlinelayout(false,fill)">
                    <text >@{name}</text>
                </container>
                             
            </listItem>
            ]]>
                        </_renderer>
                        <_items >@{m2mcontacts}</_items>
                    </list>
                </scrollpane>
            </container>
           
         
        </tabitem>
       
    </tabfolder>
    <screenfirstmenu onAction="options">Options</screenfirstmenu>
    <screenSecondMenu onAction="hide"></screenSecondMenu>
   
</screen>

 

and one morething i need to display seperate options for each tab item. Means Whenever i click the screenfirstmenu options i need to display different popup for each tabitem...

 

Regards,

Suresh A

You XML syntax is correct, except that you could replace all

<text >@{name}</text>

by

<text >${name}</text>

Because only the _items attribute need to be binded.

Then I think that to problem comes from your DataProvider. Does it deliver calllogs, contacts and m2mcontacts items ?

HI Tofu,

 

Thanks for reply. I used whatever you gave changes. But i didnt get. May be my dataprovider class is the problem. I attached my dataprovider code here. Please see and give me the response for this.

 

public class CallLogsDataprovider extends DataProvider {

    public static final String CONTACT_PROPERTY = "contacts";
    private static final String NAME_PROPERTY = "name";
 
    // create a value variable
    public String contact = "unknown";
    // ContactList's name
    public String name;

  
    /**
     * @param name the name to set
     */
    public void setName(String name) {
        this.name = name;
        dispatchUpdateEvent(NAME_PROPERTY);
    }

    // override the parent method to handle user defined value
    protected Object getUserDefinedValue(String property) {
        if (NAME_PROPERTY.equals(property)) {
            return this.name;
        }
     

        // default behavior if the property has not been found
        return null;
    }

    public boolean createContactList(String name) {
        if (name != null && name.length() > 0) {

            System.out.println("pad open create contactlist------");

            // Create the model
            CallLogsDataprovider contactList = new CallLogsDataprovider();
            contactList.setName(name);
            // Add shopList model
            addItem(CONTACT_PROPERTY, contactList);


            return true;
        }
        return false;
    }
}

 

and I need seperate options for each tab items. That one also i need please help me both on this..

 

Regards,

Suresh A

 

What you need to know is that you need a tree of dataproviders.

One root dataprovider that could contains "contacts", "calllogs" and "m2mcontacts" items.

And one DataProvider instance for each contact, calllog, and m2mcontact.

With some lines of code it could be :

DataProvider rootDataProvider = new DataProvider();

// Loop on calllogs

rootDataProvider.addItem(new CallLogDataProvider("Call log Name"));

...

// Loop on contacts

rootDataProvider.addItem(new ContactDataProvider("Contact Name"));
...

// Loop on m2mcontacts

rootDataProvider.addItem(new M2MContactDataProvider("M2MContact Name"));
...

Kuix.loadScreen("myScreen.xml", rootDataProvider);