Configuring the SearchNavButton Object
To add a search or filter functionality using a SearchNavButton, you must add an ISearchFieldListener to it. To do so, you must override the createSearchNavButton() method in the [ViewName]ControllerImpl class. In this class, you must call the super method to initially create the SearchNavButton and then add the listener. The most important part in the ISearchFieldListener is the onQueryTextSubmit() method which is invoked when the user wants to start the search.
Use the following code to override the createSearchNavButton() method:
nUISearchNavButton createSearchNavButton(int nuiid, String text, Image icon) {
nUISearchNavButton searchNavButton =
super.createSearchNavButton(nuiid, text, icon);
searchNavButton.setSearchFieldListener(new ISearchFieldListener() {
public void onTextChanged(String newText) {
// could be used to implement search-while-you-type
}
public void onQueryTextSubmit(String query) {
// start the search
}
public void onCancelButtonClicked() {
// reset the searched/filtered elements
}
});
return searchNavButton;
}
Related Topics