Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7761083
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T14:03:27+00:00 2026-06-01T14:03:27+00:00

I am writing an app for android and i am trying to have part

  • 0

I am writing an app for android and i am trying to have part of the string hyperlinked to another page within the app, but am struggling as to how to do it.

I have managed to get it to work with a whole textview like this:

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"));
        }
    });     

however this means that the string has to be on a compleatly new line (or so i believe).

What i would like is to be able to do as the notes in the code below show:

        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"));
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T14:03:28+00:00Added an answer on June 1, 2026 at 2:03 pm

    after 4 hours of searching and tweaking i have the answer:

    TextView txtVirus = (TextView) findViewById(R.glossaryMalwareID.virusmain);
    
        // this is the text we'll be operating on
        SpannableString text = new SpannableString("A Computer Virus is a small peice of Software. to make this easier to");
    
        //stops it from flickering to another colour when string is pressed.
        text.setSpan(new ForegroundColorSpan(Color.WHITE), 0, 69, 0);
    
        // make "Software" (characters 37 to 45) 
        //runs when clickableSpan is pressed
        ClickableSpan clickableSpan = new ClickableSpan() {
            @Override
            public void onClick(View view) {
                startActivity(new Intent ("com.digitalsecurity.app.MALWAREHOWTOPROTECT"));
            }
        };
        //this is what calls the method
        text.setSpan(clickableSpan, 37, 45, 0);
        //underlines it
        text.setSpan(new URLSpan(""), 37, 45, 0);
        //turns it blue
        text.setSpan(new ForegroundColorSpan(Color.BLUE), 37, 45, 0);
    
    
        txtVirus.setMovementMethod(LinkMovementMethod.getInstance());
    
        // shove our styled text into the TextView
        txtVirus.setText(text, BufferType.SPANNABLE);
    

    i got the help from here which also has other rather helpfull formatting options:

    http://www.chrisumbel.com/article/android_textview_rich_text_spannablestring

    i hope it helps someone else who needs the same

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have built a java server app and am trying to get my android
Hurro! I'm trying my hand at writing my first Android app, and I've hit
I am writing an Android app. I have an activity in my main project
I'm trying to get into Android app developing. My first problem is actually getting
I am writing a PhoneGap app on Android. I am trying to stay pure
I'm writing a game for Android with Scala. Now I'm trying to get the
I have an Android app with a main tab activity, and several activities within
I'm writing an Android App and I'm trying to choose which compatibility library to
I start my android app writing with modifying some example codes from the internet.
I'm currently writing an app in Android that works with the GPS. At the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.