Soru & Cevap

Rss reader da sayfadaki resimleri nasıl çekebilirim? ...

19.05.2014 - 01:02

Bir rss web sayfasından <media:content url="http://cdncms.xxx.tr/2014/05/16/resim2.jpg"> Türündeki resimlerin tamamını çekim ListView' e eklemek istiyorum.

Öncelikle resim url lerine erişebilkmek için su kodu kullanıyorum:

public ArrayList<String> getImageLinkFromXml(String strng)  {

        ArrayList<String> list=new ArrayList<String>();
        
        try {
            URL url=new URL(strng);
            HttpURLConnection conn = (HttpURLConnection) url.openConnection();

            if (conn.getResponseCode() == HttpURLConnection.HTTP_OK) {
                InputStream is = conn.getInputStream();
            
            DocumentBuilderFactory dFactory=DocumentBuilderFactory.newInstance();
            DocumentBuilder dBuilder=dFactory.newDocumentBuilder();

            Document document=dBuilder.parse(new InputSource(url.openStream()));
            document.getDocumentElement().normalize();
            
            NodeList nodeListCountry=document.getElementsByTagName("item");
            for (int i = 0; i < nodeListCountry.getLength(); i++) {
                Node node=nodeListCountry.item(i);
                Element elementMain=(Element) node;

                
                
                NodeList nodeListText=elementMain.getElementsByTagName("media:content");
                Element elementText=(Element) nodeListText.item(0);
                elementText.getAttribute("url");
                //Toast.makeText(MainActivity.this, links.toString(),Toast.LENGTH_SHORT).show();
                list.add(elementText.getChildNodes().item(0).getNodeValue());
                
                
            }
            }
            }catch (MalformedURLException e) {
            e.printStackTrace();
        }catch (ParserConfigurationException e) {
            e.printStackTrace();
        } catch (SAXException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }

        
        return list;
    }

 

<media:content url="http://cdncms.xxx.tr/2014/05/16/resim2.jpg">  url lere erisim icin media:content yazdıgımda ,,,, şeklinde alıyor linkleri.Url lere erişebilmek için ne yapmalıyım.

NodeList nodeListText=elementMain.getElementsByTagName("media:content");

Tüm urlleri ArrayList<String> çektiğimde bunları listview deki imageviewlara aktarmak istiyorum onu nasıl yapabilirim.

 

2 Görüntülenme

1 Cevap

Sitedeki sorulara cevap verebilmek için giriş yapın ya da üye olun.

picture-7494-1397646387.jpg
baranbuyuk
20.05.2014 - 05:21

UrlImageViewHelper kütüphanesini googleda aratın, indirin, projenize ekleyin ve sadece bir satır kod yazın. O her işi yapar. Kolay gelsin.