Android studio多重值为url的返回值

时间:2016-07-07 02:05:06

标签: android url android-studio hyperlink

我想在android studio中制作url。 当我创建multi var时,我可以在模拟中看到错误的单词。 以下是源代码。

content[i]有号码,title[i]有文字。

"content[1] = 1 content[2] = 2 content[3] = 3..."

"title[1] = test1 title[2] = test2 title[3] = test3..."

 for (int i = 0; i < nodeList.getLength(); i++) {

            Node node = nodeList.item(i);

            dist[i] = new TextView(this);
            contentid[i] = new TextView(this);
            title[i] = new TextView(this);

            Element fstElmnt = (Element) node;

            NodeList distList = fstElmnt.getElementsByTagName("dist");
            Element distElement = (Element) distList.item(0);
            distList = distElement.getChildNodes();

            NodeList contentidList = fstElmnt.getElementsByTagName("contentid");
            Element contentidElement = (Element) contentidList.item(0);
            contentidList = contentidElement.getChildNodes();
            contentid[i].setText(((Node) contentidList.item(0)).getNodeValue());

            NodeList titleList = fstElmnt.getElementsByTagName("title");
            Element titleElement = (Element) titleList.item(0);
            titleList = titleElement.getChildNodes();
            title[i].setText("TITLE = "
                    + ((Node) titleList.item(0)).getNodeValue() + ((Node) distList.item(0)).getNodeValue());


            title[i].setClickable(true);
            title[i].setMovementMethod(LinkMovementMethod.getInstance());

            String URL_ANSWER = "<a href='http://korean.visitkorea.or.kr/kor/bz15/where/festival/festival.jsp?cid="+ contentid[i] + "'>" + title[i] + "</a>";
            title[i].setText(Html.fromHtml(URL_ANSWER));

            // addView is best used with setting LayoutParams.
            // eg addView(view, layoutParams). The following is for simplicity.

            layout.addView(title[i]);

        }

1 个答案:

答案 0 :(得分:0)

您在网址上包含TextView,请尝试以下操作:

String URL_ANSWER = "<a href=\"http://korean.visitkorea.or.kr/kor/bz15/where/festival/festival.jsp?cid="+ contentid[i] + "\">" +"</a>";