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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T21:27:43+00:00 2026-05-25T21:27:43+00:00

I would like to enable search functionality to EditText. My requirement is like this:

  • 0

I would like to enable search functionality to EditText. My requirement is like this:
when someone types with some letter, suppose the user types ‘a’, then it should show all the words which starts with ‘a’ should be shown as a drop down list. For example, if I first typed “copy” in the EditText, if again, I cleared the EditText and tried to type “co”, then it should show the drop-down list “copy”,”come”,”cow”….
I want to enable this feature to my EditText view. It worked when I had a ListView with only a textview inside, but now that I have two textview in my ListView it doesn’t work.

This is my activity:

public class sedactivity extends Activity {


ListView lview;
ListViewAdapter lviewAdapter;
EditText ed;

private static final String first[] = {
    "America",
    "Busta",
    "Cactus",
    "Fire",
    "Garden",
    "Hollywood",
    "King",};

private static final String second[] = {
    "Uniti",
    "Chiusa",
    "Verde",
    "Fiamme",
    "Aperto",
    "Boulevard",
    "Kong",};

private ArrayList<String> arr_sort= new ArrayList<String>();
int textlength=0;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    ed = (EditText)findViewById(R.id.EditText1);
    lview = (ListView) findViewById(R.id.listView2);
    lviewAdapter = new ListViewAdapter(this, first, second);


    System.out.println("adapter => "+lviewAdapter.getCount());

    lview.setAdapter(lviewAdapter);

    lview.setTextFilterEnabled(true);



    ed.addTextChangedListener(new TextWatcher() {



    public void afterTextChanged(Editable s) {
    }
    public void beforeTextChanged(CharSequence s, int start, int count, int after) {
    }
    public void onTextChanged(CharSequence s, int start, int before, int count) {
            textlength=ed.getText().length();
            arr_sort.clear();
            for(int i=0;i<first.length;i++)
            {
            if(textlength<=first[i].length())
            {
            if(ed.getText().toString().equalsIgnoreCase((String) first[i].subSequence(0, textlength)))
            {
            arr_sort.add(first[i]);
            }
            }
            }

        }});}

}

And this is my ListView Adapter

public class ListViewAdapter extends BaseAdapter{
Activity context;
String title[];
String description[];

public ListViewAdapter(Activity context, String[] title, String[] description) {
    super();
    this.context = context;
    this.title = title;
    this.description = description;
}

public int getCount() {
    // TODO Auto-generated method stub
    return title.length;
}

public Object getItem(int position) {
    // TODO Auto-generated method stub
    return null;
}

public long getItemId(int position) {
    // TODO Auto-generated method stub
    return 0;
}

private class ViewHolder {
    TextView txtViewTitle;
    TextView txtViewDescription;
}

public View getView(int position, View convertView, ViewGroup parent)
{
    // TODO Auto-generated method stub
    ViewHolder holder;
    LayoutInflater inflater =  context.getLayoutInflater();

    if (convertView == null)
    {
        convertView = inflater.inflate(R.layout.listitem_row, null);
        holder = new ViewHolder();
        holder.txtViewTitle = (TextView) convertView.findViewById(R.id.textView1);
        holder.txtViewDescription = (TextView) convertView.findViewById(R.id.textView2);
        convertView.setTag(holder);
    }
    else
    {
        holder = (ViewHolder) convertView.getTag();
    }

    holder.txtViewTitle.setText(title[position]);
    holder.txtViewDescription.setText(description[position]);

return convertView;
}

}

  • 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-25T21:27:44+00:00Added an answer on May 25, 2026 at 9:27 pm

    I think an AutoCompleteTextView might be more suitable to implement this feature.

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

Sidebar

Related Questions

I would like to enable/disable some code based on a custom solution configuration I
I'd like to create an addon for Firefox that would enable me to search
I have searched and found nothing on this. I would like some advice or
I would like to enable users of my application to define a number of
I have a UITextField that I would like to enable auto completion on by:
I have a WPF ListBox that I would like to Enable multiple selection in
I would like to be able to search for a folder by name within
I have an NSTextField that I would like to enable as-you-type spell checking. When
I'd like to enable users to upload and watch videos on my website. This
I would like to enable auto-deploy on glassfish. Thanks to Nacho for pointing out

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.