One way to add links under Android programming TextView

Source: Internet
Author: User

Original address: http://www.cnblogs.com/sunzn/p/3406013.html

Link styles, click events, and href styles are supported by links to TextView added in this way, with the following code:

Package Cn.sunzn.tlink;import Android.app.activity;import Android.os.bundle;import android.text.html;import Android.text.spanned;import Android.text.method.linkmovementmethod;import Android.view.menu;import Android.widget.textview;public class Mainactivity extends Activity {    protected void onCreate (Bundle Savedinstancestate) {        super.oncreate (savedinstancestate);        Setcontentview (r.layout.activity_main);        TextView TV_SUNZN = (TextView) Findviewbyid (R.ID.TV_SUNZN);        Tv_sunzn.setmovementmethod (Linkmovementmethod.getinstance ());        spanned text = html.fromhtml ("Blog Park homepage: <a href=\" http://www.cnblogs.com/kabu/">kabu</a>");        Tv_sunzn.settext (text);    }    public boolean Oncreateoptionsmenu (Menu menu) {        getmenuinflater (). Inflate (R.menu.main, menu);        return true;    }}

One way to add links under Android programming TextView

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.