开发者

XML Parsing Problem (DOM & SAX Parsing) to print the corresponding data of Item (main tag)

开发者 https://www.devze.com 2023-03-13 03:57 出处:网络
I am doing Doing Dom Parsing from a news website for my android project. But i am finding a trouble.

I am doing Doing Dom Parsing from a news website for my android project. But i am finding a trouble.

I want to print the title element of the item tag (main tag).. in the list. And i did it. but i want when i click on the list item the corresponding data (example link, publishdate, title, description) will print in the 开发者_运维知识库next intent.For printing the titles in the list only titles of the items came in the array that i am pouring in the list.The remaining data is not coming in the array. So i am confusing in this problem. Can anybody suggest me appropriate suggestion.

Code for printing titles in the list is following :-

Here "messages" is a list. and "msg" is the object of Message class which has getter nd setter method.

    loadFeed(){
    try{
        BaseFeedParser parser = new BaseFeedParser();
        messages = parser.parse();
        List<String> titles = new ArrayList<String>(messages.size());
        for (Message msg : messages){
            titles.add(msg.getTitle());
        }
        ArrayAdapter<String> adapter = 
            new ArrayAdapter<String>(this, R.layout.row,titles);
        this.setListAdapter(adapter);
    } catch (Throwable t){
        Log.e("BBCNews",t.getMessage(),t);
    }


I see that you use the BaseFeedParser class, so I guess, you started with this article.

The missing data is in the Message object. Actually you just pass the title strings to your array adapter. So now, if you touch one of the titles, you have to (1) get the selected title and (2) look up the corresponding Message object for that title. Then you use this Message object to feed your new intent.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号