Android: SearchBox -> fill hint list dynamically with data received via HTTP/JSON
I've been looking into the Android SDK's example of the SearchableDictionary for a while now, but I'm still not sure if that is the right approach.
The problem is, that I want to fill my hint list (see picture below) with data, which I will receive via a HTTP/JSON query. So I'm not sure if using a Conte开发者_运维知识库ntProvider as used in the above example is the right thing to do. Can I access the hint list of the SearchBox in some way more direct?
You can overload the onSearchRequested for the searchmanager and return a custom data set the the given query. make sure to use an asyncTask if you are connecting to the web for your data to avoid ANR's
@Override
public boolean onSearchRequested() {
Bundle appData = new Bundle();
appData.put...();
...
startSearch(null, false, appData);
return true;
}
精彩评论