0 Replies - 342 Views - Last Post: 25 September 2016 - 03:39 AM

#1 mohammad_gholeh   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 18
  • Joined: 11-June 16

show data in listview

Posted 25 September 2016 - 03:39 AM

Hello,
how can show data in list view currently show in textview but show one item
this code
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.widget.TextView;

import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

import java.util.ArrayList;
import java.util.concurrent.ExecutionException;

public class MainActivity extends AppCompatActivity {
    ArrayList<FeedItem> feedItems;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        
        RssParll rssParll=new RssParll(this);
        Document d = null;
        try {
            d = rssParll.execute().get();
        } catch (InterruptedException e) {
            e.printStackTrace();
        } catch (ExecutionException e) {
            e.printStackTrace();
        }
        ProcessXml(d);

    }
    private void ProcessXml(Document data) {
        if(data != null)
        {
            feedItems=new ArrayList<>();
            Element root=data.getDocumentElement();
            Node channel = root.getChildNodes().item(0);
            
            NodeList items = channel.getChildNodes();
            for (int i=0;i<items.getLength();i++)
            {
                Node cureentchild = items.item(i);
                if (cureentchild.getNodeName().equalsIgnoreCase("item")) {
                    FeedItem item=new FeedItem();
                    NodeList itemchilds=cureentchild.getChildNodes();
                    for (int j = 0; j < itemchilds.getLength(); j++)
                    {
                        Node cureent = itemchilds.item(j);
                        if(cureent.getNodeName().equalsIgnoreCase("title"))
                        {
                            item.setTitle(cureent.getTextContent());
                        }else if(cureent.getNodeName().equalsIgnoreCase("date"))
                        {
                            item.setDate(cureent.getTextContent());
                        }else if(cureent.getNodeName().equalsIgnoreCase("author"))
                        {
                            item.setAuthor(cureent.getTextContent());
                        }else if(cureent.getNodeName().equalsIgnoreCase("description"))
                        {
                            item.setDescription(cureent.getTextContent());
                        }
                        //Log.d("textcontent",cureent.getTextContent());
                    }
                    feedItems.add(item);
                    Log.d("itemTitle",item.getTitle());
                    Log.d("itemDate",item.getDate());
                    Log.d("itemAuthor",item.getAuthor());
                    Log.d("itemDescription",item.getDescription());



                }

            }
            

            TextView tv1 = (TextView) findViewById(R.id.textView);
            TextView tv2 = (TextView) findViewById(R.id.textView2);

                tv1.setText(feedItems.get(0).getTitle());
                tv2.setText(feedItems.get(0).getDescription());
        }
    }

}



how can make list view Very Thanks for any one help me

Is This A Good Question/Topic? 0
  • +

Page 1 of 1