#SupportedOrientations: unspecified
#CanInstallToExternalStorage: False
#End Region
#AdditionalRes: ..\resource
#AdditionalRes: C:\Program Files (x86)\Anywhere Software\Basic4android\Libraries\resource\b4a_appcompat, de.amberhome.objects.appcompat
#AdditionalRes: D:\android sdk\extras\android\support\v7\appcompat\res, android.support.v7.appcompat
#Extends: android.support.v7.app.ActionBarActivity
#Region Activity Attributes
#FullScreen: False
#IncludeTitle: True
#End Region
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Private ActionBar As ACToolBarLight
Private pContent As Panel
Dim si As ACMenuItem
Dim sv As ACSearchView
End Sub
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
Activity.LoadLayout("main")
'Set the Toolbar (from the loaded layout) as the ActionBar of this activity.
ActionBar.SetAsActionBar
'Set Title and Subtitle for the Toolbar
ActionBar.Title = "AppCompat"
ActionBar.SubTitle = "SearchView Example"
'Because the Toolbar is part of out layout we split up our layout in a main layout file
'(which only has the Toolbar and a ContentPanel) and a content layout which has all the
'visible controls.
pContent.LoadLayout("content")
'Initialize the SearchView (make it Iconified by default)
sv.Initialize("Search")
sv.IconifiedByDefault = True
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
'Inline Java code to initialize the Menu
#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
'This is the Sub called by the inline Java code to initialize the Menu
Sub Activity_CreateMenu(Menu As ACMenu)
'Clear the menu
Menu.Clear
'Add a menu item and assign the SearchView to it
si = Menu.Add2(1, 1, "Search", Null)
si.SearchView = sv
End Sub
'If the user submits a search then this event sub is called
Sub Search_QuerySubmitted (Query As String)
sv.Iconfied = True
si.ItemCollapsed = True
Msgbox("Search for '" & Query & "'", "Search")
End Sub