1

我有一个用 html 格式的 textviewHtml.fromHtml() 当我点击时,例如,在一个 href 中,一个浏览器被启动。我想要的是处理这个意图,而不是启动浏览器。

这是我的代码:

notic = Html.fromHtml(noti.getDescripcion());                
noticiacorregida = CorrigeLinks(notic);
lbl_descripcion.setText(noticiacorregida);
lbl_descripcion.setMovementMethod(LinkMovementMethod.getInstance());

我需要将 URL 保存在变量中,而不是启动浏览器。

谢谢

4

1 回答 1

0

Well, the best I can come up with is make a webview. Use this code. First here is the java.

 package com.stackoverflow.images.webview;

import android.app.*;
import android.os.*;
import android.view.*;
import android.widget.*;
import android.content.*;
import android.webkit.*;

public class Site extends Activity
{
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.image);
        WebView webView = (WebView) 
        findViewById(R.id.webview); 
          webView.loadUrl("http://examplesite.com/yourimage");

      }


}

Now here is the XML. Try only to change the package up above in the JAVA and the url. Make sure everything is correct with JAVA up above like the onCreate layout

 <?xml version="1.0" encoding="utf-8"?>
<WebView
    android:id="@+id/webview"
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
       android:layout_height="fill_parent"
        android:orientation="vertical"
>

    </WebView>
于 2012-09-29T12:08:29.773 回答