×

Discussion Board

Results 1 to 6 of 6

Thread: LWUIT Tabs

  1. #1
    Registered User
    Join Date
    Jul 2012
    Location
    India
    Posts
    103

    LWUIT Tabs

    Hi.
    i have created LWUIT Tabs like this,i want to identify the enduser tab click event and need to place some logic?
    Here my Code:
    Tabs tabs = new Tabs();
    tabs.addTab("Tab1");
    tabs.addTab("Tab2");
    tabs.addTab("Tab3");
    tabs.addTabsFocusListener(new FocusListener() {

    public void focusGained(Component cmpnt) {
    //how to identify the enduser tab click event?
    }

  2. #2
    Nokia Developer Expert
    Join Date
    May 2012
    Location
    Espoo
    Posts
    224

    Re: LWUIT Tabs

    Hi pavanragi,

    tabs.addTab has following three signatures
    addTab(Button tab, Component component)
    addTab(java.lang.String title, Component component)
    addTab(java.lang.String title, Image icon, Component component)
    so your application should look like this
    Tabs tabs = new Tabs();
    tabs.addTab("Tab1", component1);
    tabs.addTab("Tab2", component2);
    tabs.addTab("Tab3", component3);
    tabs.addTabsFocusListener(new FocusListener() {

    public void focusGained(Component cmpnt) {

    if(cmpnt.instanceOf(component1)){
    //your logic for component1
    } else if(cmpnt.instanceOf(component2)){
    //your logic for component2
    } else if(cmpnt.instanceOf(component3)){
    //your logic for component3
    }
    }

  3. #3
    Registered User
    Join Date
    Jul 2012
    Location
    India
    Posts
    103

    Re: LWUIT Tabs

    Hi bandarap,
    thanks for reply,i have my tabs like this
    tabs.addTab("Tab1", newsList);
    tabs.addTab("Tab2", myNewsList);
    tabs.addTab("Tab3", cinemaNewsList);
    i am having three list references like above,can you tell me how to identify user click event on tabs?
    Is the belowcode correct?
    public void focusGained(Component cmpnt) {

    if(cmpnt.instanceOf(newsList)){
    //your logic for component1
    } else if(cmpnt.instanceOf(myNewsList)){
    //your logic for component2
    } else if(cmpnt.instanceOf(cinemaNewsList)){
    //your logic for component3
    }
    }
    but here ,i am not getting instaceof method ?





    Quote Originally Posted by bandarap View Post
    Hi pavanragi,

    tabs.addTab has following three signatures


    so your application should look like this
    Last edited by pavanragi; 2012-09-27 at 11:32.

  4. #4
    Nokia Developer Expert
    Join Date
    May 2012
    Location
    Espoo
    Posts
    224

    Re: LWUIT Tabs

    instanceof should be used like below:
    if(object instanceof ClassName){}

    something like:
    if(newsList instanceof List){}
    from the above code, all of your tabs are List. so they all are instance of same class. in this case '==' operator can be used to check the equality of the objects.

    read Java comparing objects http://en.wikibooks.org/wiki/Java_Pr...paring_Objects

  5. #5
    Registered User
    Join Date
    Jul 2012
    Location
    India
    Posts
    103

    Re: LWUIT Tabs

    HI Bandarap,
    i have gone through document,bit List is not a Userdefined class,how can i write my logic,if you have idea can you provide me sample code?

  6. #6
    Registered User
    Join Date
    Sep 2012
    Posts
    31

    Re: LWUIT Tabs

    Even though you add the list the onfocusGained and lost methods the component you get is radio button it is not a list (considering the way you added the tabs) try to use this tabs.getSelectedIndex() in tabs.addTabsFocusListener this gives the tab being selected.hope this will solve your issue .

    Or

    you can go with getting the name using ((RadioButton)cmp).getText() in focus gained or lost . Compare the tabs names
    you gave and do the further logic impelmentation.It worked for me try this .
    Last edited by venky2810; 2012-10-03 at 09:53.
    Regards,
    Venkatesh

Similar Threads

  1. How to work with LWUIT TABs click events
    By pavanragi in forum Mobile Java General
    Replies: 3
    Last Post: 2012-08-30, 12:22
  2. LWUIT NUMBER OF TABS
    By pavanragi in forum Mobile Java General
    Replies: 1
    Last Post: 2012-08-22, 08:56
  3. LWUIT Tabs creation
    By pavanragi in forum Mobile Java General
    Replies: 4
    Last Post: 2012-08-18, 08:09
  4. How to display a Form Screen on LWUIT Tabs?
    By pavanragi in forum Mobile Java General
    Replies: 3
    Last Post: 2012-08-09, 09:42
  5. LWUIT: tabs - how to mark the currently selected tab?
    By azakharo in forum Mobile Java General
    Replies: 3
    Last Post: 2011-12-09, 09:54

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×