我正在为 android 编写一个应用程序,我试图将字符串的一部分超链接到应用程序中的另一个页面,但我正在为如何做到这一点而苦苦挣扎。
我设法让它与这样的整个文本视图一起工作:
TextView txtVirus = (TextView) findViewById(R.glossaryMalwareID.txtVirus);      
txtVirus.setText(Html.fromHtml("<U>Computer Virus<U>"));        
txtVirus.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            // TODO Auto-generated method stub
            startActivity(new Intent ("com.digitalsecurity.app.GLOSSARYVIRUS"));
        }
    });     
然而,这意味着字符串必须在一个完全新的行上(或者我相信)。
我想要的是能够按照以下代码中的注释显示:
        TextView txtVirus = (TextView) findViewById(R.glossaryMalwareID.virusmain);     
    txtVirus.setText(Html.fromHtml("<br>" +
            "A Computer Virus is a small peice of " +
            "Software" +//i want the word 'software' hyperlinked to another page in my program
            "so on and so on"));