Make AutoCompletionTextView show suggestions not complement of text - android

i want to make a AutoCompletionTextView show suggestions
the behavior is to look in the data which is the ArrayAdapter and make suggestions
suggestions list will be a list of all texts that have the same sequence of characters
like i type abc and the data list have [ abc , fabc, geabcr, fgkd, abcg, meow]
and the suggestions will be [abc, fabc, geabcr ,abcg](see all suggestions have abc in them)

Related

AutoCompleteTextView list - Not displaying single word string first followed by two words string

I am new to Android application development and I am currently working on an existing Android application
I have an alphabetically sorted list of strings for the AutoCompleteTextView
and some of the strings have 2 words. when I start typing a letter then I would like to have the autocomplete list appeared such that it shows the strings sorted by the letter which i have typed
for example:
I have the list alphabetically sorted: free love, love, love letter, loveless
Now, if I type 'L' then first string shown in the autocomplete list is free love, the second string shown is Love but I would like to have Love as the first string because it start with 'L' . Thereafter it should show loveless, free love and love letter but it doesn't show in the order i have typed
Can you suggest on how to implement this in Android?

how to make a multi search dialog?

First of all excuse me for my very bad English...
I'm a very very new developer and I'm confusing so much with search operation.
Actually I want to make a food and cooking app (with a lot of recipes and so on), and I want to add a search action to it, so the user could put multiple things (such as Ingredients) and the app show him the foods that have these things in their Ingredients.
Now I have two question.
First, how can I add tags to my "recipe activities" so when the ingredient typed app knows which recipes should showes? (My recipes are not in textview, they are all in imageviews).
Second, how can I completely separate the search keywords with ","? for finding the right recipes. (example: type "tomato", "chicken", "egg" and the app shows him/her the recipes that have these things in their Ingredients.)
I know you that now you are laughing so much for my gramer :), so after you laughted enough please answer my questions. Thank You SOOOOOOOOO MUUUUUUUUUCH.
You can use something like a map for every Recipe's ingredients a-la:
class Recipe
-name:String
-ingredients:Map < String, Quantity > or Set < String >
where Quantity represents all that nasty features used in culinary like spoons, cups, pinches.
Then you can search through keys of every recipe's ingredients. Name would be a tag you've mentioned.
You can read search string, parse it (e.g. into array with regular expression) and put into Set to avoid duplicates.

Android find Text Group and Highlight in ListView

I am performing a search over Strings in an ArrayList. If the Term is found I need to highlight that term and return the a string with the word where the term is present plus a word before and after that word!
Example:
Term = “some”
Searched String = “This is my awesome test String!”
Result = “my awesome test” (“some” should be highlighted here)
First off I am useless with RegEx and wouldn’t know where to start and secondly I’m not sure how to highlight text in a ListView, there are 3 TextViews per Row and I pass an Array with Data objects to the Adapter. Can I just give the Data Object Spanndable’s for highlighting?!
After some trial and error and some help i got this which seems to do the trick
(^|\S*\s)\S*term\S*($|\s\S*)

Searchable String-Array, Android?

How can I search through an String-Array? I've got an dictionary app and the words are saved in a String-Array and it would be user-friendlier, if you could search for the word you want to look up, instead of looking its way to the word. Can somebody help?
Thanks.
You can try using an ArrayList instead. Then you can see if the word is in your 'dictionary' by using the contains method, ex:
ArrayList <String> myDictionary = new ArrayList<String>();
myDictionary.add(new String("foo"));
myDictionary.add(new String("bar"));
...
// To check if the word exists in your dictionary.
if (myDictionary.contains(new String("word_to_look_up")))
{
}
Not entirely sure what you are looking for- do you want to see if the word is in the array, or what is the goal? If you want the user to get to the word faster, changing the string-array will not help the UI jump to the right place.
If you want it to be like Google suggest you could take your array and make a tree data object, which each node representing a letter in a word. Then if the user types a, you go into that node and offer possible words.
You may use the Arrays.binarySearch() method to search an element from the sorted array.

Android : Skipping to Listview position given input char or string

Can someone tell me how to skip to a position in an alphabetically sorted ListView when given a char or string input from an onClick method?
For example, I have a dialog that passes back a char. If that char is a B I want the listview to skip to the first B entry.
Any help would be greatly appreciated.
Thanks,
Josh
If your listview contains so many entries that this is necessary, wouldn't it be beneficial to simply remove all but the "b" entries? Thus your listview would automatically show the "b's" and only the "b's." It should be pretty easy to do that if you dump the entries into a list or array object.
I realize this doesn't directly answer your question, but sometimes it can be beneficial to get outside feedback on a design aspect.
Also, doesn't
myListview.Items(X).Selected = true;
where X is your first "b" item solve the problem?

Categories

Resources