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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T15:42:56+00:00 2026-06-14T15:42:56+00:00

What im trying to accomplish is something that is standard in most twitter apps,

  • 0

What im trying to accomplish is something that is standard in most twitter apps, in a textview there may be an “@” mention or a “#” hashtag preceding a word in a text string and they are actually able to add a click listener onto that word that launches another activity, does anyone know how this is achieved? below I have attached an example photo showing what i’m trying to achieve, any help would go a long way thanks

enter image description here

  • 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-14T15:42:57+00:00Added an answer on June 14, 2026 at 3:42 pm

    Take a look at the Linkify class. It allows you to add Links within you TextViews, for a given regular expression.

    The following has been extracted from this article:

    TextView mText = (TextView) findViewById(R.id.mytext);
    Pattern userMatcher = Pattern.compile("\B@[^:\s]+");
    String userViewURL = "user://";
    Linkify.addLinks(mText, userMatcher, userViewURL);
    

    Pattern is used to create new pattern from given reguler expression like example above which catch any text like @username in the given text , then you have to define your user:// scheme this also have to be defined in activity which will catch the clicks and last one Linkify.addLinks make all of them work together. Lets look at Android.manifest file for intent filter.

    <activity android:name=”.DirectMessageActivity” > 
        <intent-filter>
            <category android:name=”android.intent.category.DEFAULT”/> 
            <action android:name=”android.intent.action.VIEW” /> 
            <data android:scheme=”user” /> 
        </intent-filter> 
    </activity>
    

    When you click @username this is the activity that will catch the click and process the clicked string. Yes we didnt mention about what is send to DirectMessageActivity when user click @username , as you might guess “username” string will be passed to DirectMessageActivity. You can get this string like this.

    Uri data = getIntent.getData();
    if(data != null){
        String uri = data.toString();
        username = uri.substring(uri.indexOf("@")+1);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am new to cakephp and I'm trying to accomplish something that should be
Im trying to accomplish something which may seem a bit convoluted but would be
There is something I am trying to accomplish although I'm not really sure where
I am new to php and trying to accomplish something that must be easy
I am trying to accomplish something in C# that I do easily in Java.
I'm pretty new to iOS animations, I've been trying to accomplish something that in
I'm trying to accomplish something that should be rather basic in CSS but I'm
I'm trying to accomplish something akin to twitter on my website, where one user
I'm trying to accomplish something fairly simple in VB that I do everyday in
I am trying to accomplish something that seemed quite simple... I have 3 div

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.