#Region Project Attributes
#ApplicationLabel: B4A Example
#VersionCode: 1
#VersionName:
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: unspecified
#CanInstallToExternalStorage: False
#End Region
#Region Activity Attributes
#FullScreen: False
#IncludeTitle: True
#End Region
#Extends: android.support.v7.app.AppCompatActivity
#AdditionalRes: ..\Resource
Sub Process_Globals
End Sub
Sub Globals
Private ACToolBarLight1 As ACToolBarLight
Private ToolbarHelper As ACActionBar
Dim pop As DroppyMenuPopup
Dim libIME As IME
Private bKeyboardVisible As Boolean
Private btnDroppy As Button
Private EditText1 As EditText
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("1")
Dim bd As BitmapDrawable
bd.Initialize(LoadBitmap(File.DirAssets, "smiley.png"))
ACToolBarLight1.NavigationIconDrawable = bd
btnDroppy.Initialize("btnDroppy")
ACToolBarLight1.AddView(btnDroppy,75dip,50dip,Gravity.RIGHT)
pop.Initialize("Droppy",btnDroppy)
Dim cb As CheckBox
cb.Initialize("cb")
cb.Text="Check Me!"
cb.Color=Colors.Red
cb.TextSize=20
cb.TextColor=Colors.White
pop.addMenuItem("Test1").addMenuItem3(cb).addMenuItem2("Test2","ic_add_alert_black_18dp").addMenuItem("Options").addclickcallback.addonDismissCallback.addSeparator.addMenuItem("Options1a").addMenuItem("Options1b").triggerOnAnchorClick(True).build
ToolbarHelper.Initialize
ToolbarHelper.ShowUpIndicator = False 'set to true to show the up arrow
ACToolBarLight1.InitMenuListener
libIME.Initialize("IME")
libIME.AddHeightChangedEvent
End Sub
Sub btnDroppy_Click
Log("btnDroppy_Click")
If bKeyboardVisible Then
HideKeyboard
End If
End Sub
Sub IME_HeightChanged(NewHeight As Int, OldHeight As Int)
bKeyboardVisible = NewHeight < OldHeight
Log("IME_HeightChanged, bKeyboardVisible: " & bKeyboardVisible)
End Sub
Sub HideKeyboard()
libIME.HideKeyboard
bKeyboardVisible = False
End Sub
Sub Droppy_onClicked(view As Object, index As Int)
Log($"Droppy_onClicked(${view}, ${index})"$)
If view Is Button Then
Log("btn")
else if view Is Label Then
Log("lbl")
else if view Is CheckBox Then
Log("chk")
else if view Is DroppyMenuItemView Then
Dim item As DroppyMenuItemView = view
Log(item.ChildCount)
If item.ChildCount = 1 Then
If item.getChildAt(0) Is Label Then
Dim lbl As Label = item.getChildAt(0)
Log(lbl.Text)
End If
End If
End If
End Sub
Sub Droppy_onDismissed()
Log($"Droppy_onDismissed()"$)
End Sub
Sub ACToolBarLight1_NavigationItemClick
Log("click1")
End Sub
Sub Activity_CreateMenu(Menu As ACMenu)
Menu.Clear
Dim item As ACMenuItem
'Menu.Add2(10, 1, "Plus one", xml.GetDrawable("ic_plus_one_black_24dp")).ShowAsAction = item.SHOW_AS_ACTION_IF_ROOM
'Menu.Add2(20, 2, "Refresh", xml.GetDrawable("ic_refresh_black_24dp")).ShowAsAction = item.SHOW_AS_ACTION_ALWAYS
item = Menu.Add(1, 3, "Overflow1", Null)
Menu.Add(2, 4, "Overflow2", Null)
Menu.Add(3, 5, "Overflow3", Null)
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
#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