如题。求解。最好有一个小例子。

解决方案 »

  1.   

    直接<a href="url">连接</a>
    在有个HTML类有个静态方法把这String类型转成Html的就行了
      

  2.   

    text.setText(Html.fromHtml("<a href='http://www.google.cn'>google</a>"));
    android:autoLink="all"
        TextView myTextView = (TextView) this.findViewById(R.id.textView1);  
        SpannableString sp = new SpannableString("这句话中有百度超链接,有高亮显示,这样,或者这样,还有斜体.");             
        sp.setSpan(new URLSpan("http://www.baidu.com"), 5, 7, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);          
        sp.setSpan(new BackgroundColorSpan(Color.RED), 17 ,19,Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);        
        sp.setSpan(new ForegroundColorSpan(Color.YELLOW),20,24,Spannable.SPAN_EXCLUSIVE_INCLUSIVE);      
        sp.setSpan(new StyleSpan(android.graphics.Typeface.BOLD_ITALIC), 27, 29, Spannable.SPAN_EXCLUSIVE_INCLUSIVE);           
        //SpannableString对象设置给TextView          
        myTextView.setText(sp);          
         //设置TextView可点击          
        myTextView.setMovementMethod(LinkMovementMethod.getInstance());
    也可以直接用html
        myTextView.setText(Html.fromHtml("<a href='http://www.google.cn'>google </a>"));
        myTextView.setMovementMethod(LinkMovementMethod.getInstance());
     
      

  3.   

    如下。xml文件中:
    <?xml version="1.0" encoding="utf-8"?>
    <resources>
        <string name="aboutus">&lt;center>&lt;b> &lt;a href="http://www.google.com">google&lt;/a>&lt;/b>&lt;/center></string>
    </resources>解析:
    public static class AboutUsBuilder{
    public static AlertDialog create(Context context) {
    String aboutTitle = context.getString(R.string.about_us_title);
    Spanned aboutText = Html.fromHtml(context.getString(
    R.string.weather_aboutus, TextView.BufferType.SPANNABLE));
    ScrollView mainView = new ScrollView(context);
    TextView message = new TextView(context);
    mainView.addView(message);
    message.setPadding(5, 5, 5, 5);
    message.setText(aboutText);
    return new AlertDialog.Builder(context).setTitle(aboutTitle)
    .setCancelable(true).setIcon(R.drawable.icon)
    .setPositiveButton(android.R.string.ok, null).setView(
    mainView).create();
    }
    }
      

  4.   

    Google到这篇文章,不过是讲实现可点击的无下划线超链接http://orgcent.com/android-textview-no-underline-hyperlink/