It's better to ask each question in its own thread if they are not really related.
1: You have to change the theme xml file. See
this or
this answer on StackOverflow.
2: This is a bit like an undocumented feature. I never found the time to write a tutorial about it.
- Initialize the SearchView with an EventName
- Set it Iconified state by default sv.IconifiedByDefault = True
- You have to use the advanced menu. I usually set it up with some java code. si is of type ACMenuItem,
UIUtils.GetBitmapDrawable just loads a drawable. Just create a menu item and assign the searchview to it:
:
#If Java
public boolean _onCreateOptionsMenu(android.view.Menu menu) {
if (processBA.subExists("activity_createmenu")) {
processBA.raiseEvent2(null, true, "activity_createmenu", false, new de.amberhome.objects.appcompat.ACMenuWrapper(menu));
return true;
}
else
return false;
}
#End If
Sub Activity_CreateMenu(Menu As ACMenu)
Menu.Clear
si = Menu.Add2(1, 1, "Add location", UIUtils.GetBitmapDrawable("ic_action_search"))
si.SearchView = sv
End Sub
- If the user presses the search menu item the ActionBar/Toolbar expands to an EditText view where he can enter his search text.
- If the user presses enter/submits the search the Search_QuerySubmitted (Query As String) event is called where you can handle the search. In this event sub you should Iconify the Searchview again:
Sub Search_QuerySubmitted (Query As String)
sv.Iconfied = True
si.ItemCollapsed = True
Do your search here.
End Sub