【问题标题】:How to do clickable ListView after HTML parsing (get "href=")HTML解析后如何做可点击的ListView(获取“href=”)
【发布时间】:2011-10-18 02:41:18
【问题描述】:

我是这样做 html 解析的 Android HTML Parser Example

现在我有一个列表视图,其中包含来自站点的搜索结果。 如何获取此商品的“href=”然后访问该站点?

谢谢..

【问题讨论】:

    标签: android html listview


    【解决方案1】:

    在下面的代码中,如果你将元素作为参数传递,你可以获得元素的href。然后你可以去现场继续。

     public static String getTagValueWithMultiItem(Element eElement){
                     String returnVal = "" ;
                     Node eNode ;
                     int NumOFItem = eElement.getElementsByTagName("link").getLength();
                     for (int y = 0; y < NumOFItem; y++) {
                     eNode = eElement.getElementsByTagName("link").item(y);
                     NamedNodeMap attributes = eNode.getAttributes();
                      for (int g = 0; g < attributes.getLength(); g++) {
                          Attr attribute = (Attr)attributes.item(g);
                                     if(attribute.getNodeName().equals("rel")&&attribute.getNodeValue().equals("alternate"))
                                        {
                                          try { 
                                                returnVal =eNode.getAttributes().getNamedItem("href").getNodeValue();
                                               }  
                                             catch (Exception e) {
                                                returnVal = e.toString();
                                             }
                                         } 
                                      }
                     }
                    return returnVal;    
                 }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-06-02
      • 2017-02-15
      • 1970-01-01
      • 2019-03-11
      • 2014-06-07
      • 2011-07-27
      • 2016-03-11
      • 1970-01-01
      相关资源
      最近更新 更多