×

Discussion Board

Results 1 to 7 of 7
  1. #1
    Registered User
    Join Date
    Jul 2012
    Location
    India
    Posts
    103

    Rss Feed Reader in j2me using LWUIT not able to display Titles

    Hii
    i want to display rss feed titles and image in a list?in this code i am trying to display rss feed titles on lwuit Form Screen,But when i run my Source Code,i am able to display,only one title,and the loop is stopping?But when i try to do the same code using lcdui list Screen,i am successfully able to display the tittles and image from rss feed url...
    //method called by the parsing thread
    USING LCDUI LIST AND FORM:
    public void addNews(News newsItem) {
    news.addElement(newsItem);
    myNewsList.append(newsItem.getTitle(), newsItem.getImage());
    myDysplay.setCurrent(myNewsList);
    }


    Here my Sample Code Using LWUIT LIST AND FORM:

    //method called by the parsing thread
    public void addNews(News newsItem) {

    myNewsList.addItem(newsItem.getTitle());
    form1.addCommandListener((ActionListener) this);
    form1.addComponent(myNewsList);
    form1.addCommand(cmdExit);
    form1.addCommand(cmdDetails);
    form1.setScrollable(true);
    form1.setTransitionInAnimator(Transition3D.createRotation(250, true));
    form1.show();
    Can you check once my Source Code?


    }

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

    Re: Rss Feed Reader in j2me using LWUIT not able to display Titles

    Hi pavaragi,

    LWUIT code looks ok. From the code I can see that only one title( myNewsList.addItem(newsItem.getTitle()) is added. To get more titles add myNewsList.addItem(newsItem.getTitle()); in a loop.

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

    Re: Rss Feed Reader in j2me using LWUIT not able to display Titles

    Hii

    i have used the loop,still only one title ,i can able to display,control is coming to there,i have used sysout,but printing only one title
    public void addNews(News newsItem) {

    news.addElement(newsItem);

    for (int i = 0; i < news.size(); i++) {


    myNewsList.addItem(newsItem.getTitle());
    form1.addComponent(myNewsList);
    }

    form1.addCommand(cmdExit);
    form1.addCommand(cmdDetails);
    form1.setScrollable(true);
    form1.setTransitionInAnimator(Transition3D.createRotation(250, true));
    //form1.addCommandListener((ActionListener) this);

    form1.show()
    }



    Quote Originally Posted by pavanragi View Post
    Hii
    i want to display rss feed titles and image in a list?in this code i am trying to display rss feed titles on lwuit Form Screen,But when i run my Source Code,i am able to display,only one title,and the loop is stopping?But when i try to do the same code using lcdui list Screen,i am successfully able to display the tittles and image from rss feed url...
    //method called by the parsing thread
    USING LCDUI LIST AND FORM:
    public void addNews(News newsItem) {
    news.addElement(newsItem);
    myNewsList.append(newsItem.getTitle(), newsItem.getImage());
    myDysplay.setCurrent(myNewsList);
    }


    Here my Sample Code Using LWUIT LIST AND FORM:

    //method called by the parsing thread
    public void addNews(News newsItem) {

    myNewsList.addItem(newsItem.getTitle());
    form1.addCommandListener((ActionListener) this);
    form1.addComponent(myNewsList);
    form1.addCommand(cmdExit);
    form1.addCommand(cmdDetails);
    form1.setScrollable(true);
    form1.setTransitionInAnimator(Transition3D.createRotation(250, true));
    form1.show();
    Can you check once my Source Code?


    }

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

    Re: Rss Feed Reader in j2me using LWUIT not able to display Titles

    check this code also:
    private void ParseXMLFeed(InputStream input)
    throws IOException, XmlPullParserException {
    Reader dataReader = new InputStreamReader(input);
    KXmlParser myParser = null;
    try {
    myParser = new KXmlParser();
    } catch (Exception e) {
    //System.out.println("hiiii" + e);
    }
    myParser.setInput(dataReader);


    myParser.nextTag();
    myParser.require(XmlPullParser.START_TAG, null, "rss");

    myParser.nextTag();
    myParser.require(XmlPullParser.START_TAG, null, "channel");
    myParser.nextTag();
    myParser.require(XmlPullParser.START_TAG, null, "title");

    while (myParser.getEventType() != XmlPullParser.END_DOCUMENT) {
    String name = myParser.getName();

    if (name.equals("channel")) {
    break;
    }

    if (name.equals("item")) {

    if (myParser.getEventType() != XmlPullParser.END_TAG) {
    myParser.nextTag();
    String title = myParser.nextText();
    myParser.nextTag();
    String link = myParser.nextText();

    myParser.nextTag();
    String pubDate = myParser.nextText();
    myParser.nextTag();

    News news = new News(title, link, pubDate, ptext);
    System.out.println("gjgjgjgdgdggggggggggg");
    parentMidlet.addNews(news); //CHECK OUT HERE ,I AM CALLING THE METHOD
    }
    } else {

    myParser.skipSubTree();
    }

    myParser.nextTag();
    }

    input.close();
    }

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

    Re: Rss Feed Reader in j2me using LWUIT not able to display Titles

    Hii bandarap

    i can able to display the second title on out put console:
    by :
    System.out.println(newsItem.getTitle());
    from rss file,but it is failing here(the loop is stopping here)
    myNewsList.addItem(newsItem.getTitle());//loop is stopping here

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

    Re: Rss Feed Reader in j2me using LWUIT not able to display Titles

    OK, addNews(news); method is already calling in a while loop, so don't have to create again another loop for myNewsList.addItem(newsItem.getTitle());
    public void addNews(News newsItem,Vector nw) {

    news.addElement(newsItem);
    myNewsList.addItem(newsItem.getTitle());
    form1.addComponent(myNewsList);
    form1.show()
    }

    move the following code from addNews() method to the place where Form is instantiated

    form1.addCommand(cmdExit);
    form1.addCommand(cmdDetails);
    form1.setScrollable(true);
    form1.setTransitionInAnimator(Transition3D.createRotation(250, true));
    form1.addCommandListener((ActionListener) this);

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

    Re: Rss Feed Reader in j2me using LWUIT not able to display Titles

    Hii

    if declare this in a constructor,facing nullpointer exception and if declare this in a startapp()method,facing the situation like one title display(second title is displaying on my out put console ,but myNewsList.addItem(newsItem.getTitle());//loop is stopping here


    public XMLMidlet() {
    news = new Vector();
    myNewsList = new List();
    cmdDetails = new Command("Details");
    form1 = new Form("Feeds List");
    form1.addCommand(cmdDetails);
    form1.setScrollable(true);
    form1.setTransitionInAnimator(Transition3D.createRotation(250, true));

    }

Similar Threads

  1. How to develop Rss Reader App using LWUIT Component in j2me(java)
    By pavanragi in forum Mobile Java General
    Replies: 1
    Last Post: 2012-07-31, 11:09
  2. N8 Problem displaying camera feed to touchscreen display.
    By singhzubin in forum Symbian Media (Closed)
    Replies: 2
    Last Post: 2010-10-15, 00:00
  3. LWUIT Display
    By Arunesh in forum Mobile Java General
    Replies: 1
    Last Post: 2009-09-06, 12:17
  4. Replies: 7
    Last Post: 2009-05-27, 06:27

Posting Permissions

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