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 8238135
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T19:42:20+00:00 2026-06-07T19:42:20+00:00

How to move to another view by click on text view with two different

  • 0

How to move to another view by click on text view with two different words.
this is the string i am using.

By clicking Sign Up, you are indicating that you have read and agree to the 
Term of Use and Privacy Policy.

i want to make these two words (Term of Use, Privacy Policy) in different color and clickable..

i know ho to make color for a particular word. i want to make it clickable .

  • 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-07T19:42:23+00:00Added an answer on June 7, 2026 at 7:42 pm

    I finally figured it out how to have multiple clickable parts in a TextView.
    It is important that they all have their own ClickableSpan! That is where I went wrong the first time testing it. If they have the same ClickableSpan instance, only the last set span is remembered.

    I created a String with the required clickable area’s surrounded by “[” and “]”.

    String sentence = "this is [part 1] and [here another] and [another one]";
    

    and here is the set TextView, the setMovementMehthod is also mandatory:

    textView.setMovementMethod(LinkMovementMethod.getInstance());
    textView.setText(addClickablePart(sentence), BufferType.SPANNABLE);
    

    I have created this function, which will handle the creation of the clickable area’s:

    private SpannableStringBuilder addClickablePart(String str) {
        SpannableStringBuilder ssb = new SpannableStringBuilder(str);
    
        int idx1 = str.indexOf("[");
        int idx2 = 0;
        while (idx1 != -1) {
            idx2 = str.indexOf("]", idx1) + 1;
    
            final String clickString = str.substring(idx1, idx2);
            ssb.setSpan(new ClickableSpan() {
    
                @Override
                public void onClick(View widget) {
                    Toast.makeText(getView().getContext(), clickString,
                            Toast.LENGTH_SHORT).show();
                }
            }, idx1, idx2, 0);
            idx1 = str.indexOf("[", idx2);
        }
    
        return ssb;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using navigation controller to move from one view to another ... i
I'd like to move items from one list view to another. adding them to
i'm trying to move folders to another folders using command line , with overwrite
I'm trying to move a control from one parent to another (if this will
I want to move image to another x,y position. I try this code but
How can I move from the current view to another view? My current view
I have a bunch of records I want to move to another database and
How would i go about making an animation of a rocket move to another
Basically I want to move files to another server on creation preserving the directory
When I move a user story from one iteration to another in TFS 2010,

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.