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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T21:21:18+00:00 2026-06-04T21:21:18+00:00

Im currently making a search engine like application for android and i want to

  • 0

Im currently making a search engine like application for android and i want to highlight the searched word from edittext to textview… this is that i got so far and it only highlights the first word in the textview

TV.setText("Hello World", TextView.BufferType.SPANNABLE);
            Spannable WordtoSpan = (Spannable) TV.getText();
            WordtoSpan.setSpan(new BackgroundColorSpan(0xFFFFFF00), 0, notes.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
            TV.setText(WordtoSpan);
  • 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-04T21:21:19+00:00Added an answer on June 4, 2026 at 9:21 pm

    I think you want to highlight a specific word of TextView which user types in a EditText.
    Say et is your EditText and tv is TextView object. Use the following code:


        String ett =et.getText().toString();
        String tvt =tv.getText().toString();
    
                    int index = tvt.indexOf(ett);
    
                    Spannable WordtoSpan = new SpannableString( tv.getText() );
                    if(index != -1)
                    {
                    WordtoSpan.setSpan(new BackgroundColorSpan(0xFFFFFF00), index, index+ett.length(),Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
                    tv.setText(WordtoSpan, TextView.BufferType.SPANNABLE);
                    }
                    else
                    tv.setText("The name of our country is Bangladesh");
    

    Here is the outcome:

    enter image description here


    Here is the complete code:

     public class MotivationalQuotesActivity extends Activity {
            /** Called when the activity is first created. */
    
       Button next;
       EditText et; 
       TextView tv;
            @Override
            public void onCreate(Bundle savedInstanceState) {
                super.onCreate(savedInstanceState);
                setContentView(R.layout.main);
           et = (EditText) findViewById(R.id.et);
           tv = (TextView) findViewById(R.id.tv);
           tv.setText("The name of our country is Bangladesh");
    
           next = (Button) findViewById(R.id.button1);
            next.setOnClickListener(new OnClickListener() {
    
                    public void onClick(View v) {
                        // TODO Auto-generated method stub
    
                        String ett =et.getText().toString();
                        String tvt =tv.getText().toString();
    
                        int index = tvt.indexOf(ett);
    
                        Spannable WordtoSpan = new SpannableString( tv.getText() );
                        if(index != -1)
                        {
                        WordtoSpan.setSpan(new BackgroundColorSpan(0xFFFFFF00), index, index+ett.length(),Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
                        tv.setText(WordtoSpan, TextView.BufferType.SPANNABLE);
                        }
                        else
                        tv.setText("The name of our country is Bangladesh");
    
    
                    }
                });
    
            }
    
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently making a rails app that will search #barcampmlk2 #{thesessionname} +1 from
i'm currently making search engine for a website content (only for searching within that
I am currently making a website where I require a very advanced search engine.
I am making a search engine for my Android app that involves a database.
I'm currently making an iphone web app based on Google App Engine (python). I
I'm currently making some system that will gather statistical reports from different sites, for
Hi i am currently making a demo site from just pure html/css/javascript usually i
At school we are busy making a Spotify application. I am currently making an
I'm making a web application and I got the design for it from a
I'm currently making a Drag-and-Drop engine in JavaScript. I'm currently working on making bounds

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.