2

I have a problem with Android. When you are using AutoCompleteTextView :

AutoCompleteTextView textView = (AutoCompleteTextView) findViewById(R.id.entry);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, R.layout.url_addresses);

String[] url_addresses = getResources().getStringArray(R.array.url_addresses);
for (String string : url_addresses) {
    adapter.add(string);
}

textView.setAdapter(adapter);
.....

And when you entered the "google" keyword in textbox, auto complete system showing all urls which is start with "google". For example:

  • google.com
  • google.com.tr
  • google.co.uk

But, I want to show urls which is contains "google". For example:

  • http://www.google.com/
  • https://mail.google.com/
  • http://another.google.com/

I think this problem occurred if item does not contains any space (one word, like url).

It is possible?

Thanks a lot.

2 Answers2

0

IIRC, Write your own adapter instead of using the base ArrayAdapter. See the Filter.performFiltering... Android AutoCompleteTextView with Custom Adapter filtering not working

Community
  • 1
  • 1
maxweber
  • 576
  • 1
  • 5
  • 12
0

That should be simple. Wrap the url string into another class and in toString return the url with dots replaced with spaces. For example, The url http://mail.google.com will be returned as http://mail google com which will be matched easily by the filter. You can replace other characters also similarly before returning the string seperated by spaces. Like //

class urlString {

   String url;
   public String toString() {
       return url.replace('.',' ');// replace dots with space
   }
}
Ron
  • 24,175
  • 8
  • 56
  • 97
  • Thanks for your reply. It can be a good idea. But URL list would be complicated. If I make a URL address changes, the list will be updated. – Mustafa Kirimli Sep 17 '11 at 15:00