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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T11:30:30+00:00 2026-05-27T11:30:30+00:00

I am creating one application in which I am searching for a Perticular word

  • 0

I am creating one application in which I am searching for a Perticular word in text view.I have one edit text,one text view and one button,when I am entering any word in edit text and clicking on button it gives me the line position and position of word in that line from entire text file…I have append text file’s contain in text view…now my question is can I highlight that all word which is there in text view entered by edit text.?if I can than please tell me how to do it..if any one have idea of it?

  • 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-05-27T11:30:31+00:00Added an answer on May 27, 2026 at 11:30 am

    You can also do it by using a Spannable, which is convenient as you know the position of the word:

        SpannableString res = new SpannableString(entireString);
        res.setSpan(new ForegroundColorSpan(color), start, end, SpannableString.SPAN_EXCLUSIVE_EXCLUSIVE);
    

    Where entireString is the string in which the word to highlight exists, color is the color you want the hightlighted text to have, start is the position of the word and end is where the word ends (start+word.length()).

    The SpannableString res can then be applied to your textview like a regular string:

    textView.setText(res);
    

    Note: If you want the background of the text to get a color rather than the text itself, use a BackgroundColorSpan instead of a ForegroundColorSpan.

    Edit:
    In your case it would be something like this (you will have to save the value of linecount and indexfound for when you read the entire text):

    for(String test="", int currentLine=0; test!=null; test=br2.readLine(), currentLine++){
        if(currentLine==linecount){
            SpannableString res = new SpannableString(test);
            res.setSpan(new ForegroundColorSpan(0xFFFF0000), indexfound, indexfound+textword.length(), SpannableString.SPAN_EXCLUSIVE_EXCLUSIVE);
        }
        tv.append("\n"+"    "+test);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am creating one application which convert text into speech in Indian English. I
I am creating one web application in which I am showing watermark text for
I am creating one application with jquery.mobile-1.0a4.1 release. I have a page which is
I have an c# application which owns 2 threads. One thread is creating an
I'm creating an iPad application which needs a UIPopoverController like this one (I mean,
I am creating an application for the iPhone which involves having more than one
I am creating one GUI in swing Java. I have to use one button
I am creating one desktop application in which I want to track user activity
I am creating one application in .net MVC, in which I am using jQuery
I am creating application which is having functionality like 1 person can view video

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.