autocomplete question

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

autocomplete question

Postby dmc1024 » Sat Jan 24, 2009 8:30 am

hey guys i'm just starting out in android and i've been trying to get some basic autocomplete working.
i've seen the api demos, and this chunk of code is what i'm using so far

(from autocomplete1)
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
android.R.layout.simple_dropdown_item_1line, COUNTRIES);
AutoCompleteTextView textView = (AutoCompleteTextView) findViewById(R.id.edit);
textView.setAdapter(adapter);


what i REALLy want is , when i'm typing in whatever i want to search for, instead of a window being created each time, is it possible to just display the results from this windows, in a separate list view? (say directly below the text box)

any ideas how to do this? it would appear that the "autocomplete" window is linked to the widget so i can't get rid of it.

edit: perhaps i was too confusing: basically i want to take the autocomplete widget, and instead of having a window pop up each time it "Searches" for an autocomplete, i just want that window to appear below permanently
dmc1024
Freshman
Freshman
 
Posts: 8
Joined: Sat Jan 24, 2009 8:27 am

Top

Postby dmc1024 » Thu Feb 05, 2009 6:27 pm

just to let anybody who is interested know.
i ended up making my own widget.

so i just have an editview and a listview sticked on top of each other
in vertically on a simple linear layout.

then for the editview, i added the textchangelistener,
and when that happens,
i have the listView update, which is essentially reset the list of items.

to simulate the "autocomplete" function, i take on a very search algorithm, which is
for each string in the list, i tokenize them by white space, and then I go through each word
and see if it BEGINS with whatever character sequence is in the editView.

so e.g
if the list contains:

Billie Is the Best
Biso Is the Best
Drew Is the Best


And you search for "Bi"

you will get the first two results

(similar is you search for "Is", you'll get all three results, but i'll work on that)

please feel free to pm me.

(p.s the search algorithm is implaced into the widget with the strategy pattern, so it will most likely be improved later on)
dmc1024
Freshman
Freshman
 
Posts: 8
Joined: Sat Jan 24, 2009 8:27 am

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: No registered users and 3 guests