2

我的应用程序在线从服务器检索数据。如果我在应用程序中插入像 Hello 这样的服务器,如果您点击上方,请不要引导任何地方。为什么?这是来源

MyText = (TextView) this.findViewById(R.art.tit);
        Text = (TextView) this.findViewById(R.artic.text);
        String formattedText = db.getTesto();
        String formattedTitle = db.getTitolo();
        MyText.setText(Html.fromHtml(formattedTitle));
        Text.setText(Html.fromHtml(formattedText));
4

3 回答 3

0

在 android 中,您可以通过两种方式添加链接, - 在android:autoLink="web"textview 的 XML 设计中,它会将您带到网络浏览器 onclick - 如果您想添加代码,您可以添加类似

TextView yourTextview= (TextView) findViewById(R.id.noteview); yourTextview.setText(youURL link); Linkify.addLinks(yourTextview, Linkify.ALL);

谢谢。

于 2013-07-24T06:08:56.927 回答
0

这是超链接的示例:

MyText = (TextView) this.findViewById(R.art.tit);
Text = (TextView) this.findViewById(R.artic.text);
tv1.setLayoutParams(textOutLayoutParams);
tv1.setText(Html.fromHtml("<a href=\""+ formattedText + "\">" + formattedTitle + "</a>"));
tv1.setClickable(true);
tv1.setMovementMethod (LinkMovementMethod.getInstance());
dialogLayout.addView(tv1);
于 2013-07-24T04:47:59.043 回答
0

I finally got it working using the following code :

TextView tv1 = new TextView(this);
tv1.setLayoutParams(textOutLayoutParams);
tv1.setText(Html.fromHtml("<a href=\""+ l.getRightString() + "\">" + l.getLeftString() + "</a>"));
tv1.setClickable(true);
tv1.setMovementMethod (LinkMovementMethod.getInstance());
dialogLayout.addView(tv1);

l.getRightString() - contains a url like: http:\www.google.com
l.getLeftString() - contains text for the url like: "Go to Google"

RESULTS: Text "Go to Google" on my dialog with blue color and underlined, and on clicking it the browser opens up and shows the respective page.
On returning/Exiting the browser it again comes to the app from the state where it had left.

Hope this helps.

于 2013-07-24T04:48:35.303 回答