Sub Process_Globals
End Sub
Sub Globals
Dim Exit As Button
Private Help As Button
Private GN As Button
Private GC As Button
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("gmain")
End Sub
Sub Help_Click
StartActivity("Help1")
End Sub
Sub GN_Click
StartActivity("G_N")
End Sub
Sub GC_Click
StartActivity("G_C")
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub Exit_Click
ExitApplication
End Sub
Sub FocusButton(Button As Button)
Dim JO As JavaObject = Button
JO.RunMethod("setFocusable",Array As Object(True))
JO.RunMethod("setFocusableInTouchMode",Array As Object(True))
Button.RequestFocus
End Sub
Private Sub setActivePallet(intIndex As Int)
Dim lbl As Label
Dim cd As ColorDrawable
Dim intColor As Int
' Store index of selected user pallet
intActiveUserPallet = intIndex
' Loop through each user pallet to set/reset border colour
For intIndex = 0 To mapUserColors.Size - 1
intColor = mapUserColors.GetValueAt(intIndex)
lbl = mapUserColors.GetKeyAt(intIndex)
If lbl.Tag = intActiveUserPallet Then
' Highlighted border of selected pallet
cd.initialize2(intColor, 5dip, 2dip, Colors.Yellow)
intARGB = getARGBColor(intColor)
Else
' Reset border color if not selected
cd.initialize2(intColor, 5dip, 1dip, Colors.Red)
End If
lbl.Background = cd
mapUserColors.Put(lbl, intColor)
Next
End Sub
FocusButton(Help)
Sub FocusButton(Button As Button)
Sub SetUpOnFocusListener(Button As Button, EventName As String)
FocusButton(Button) 'This will let us focus the button.
Dim JO As JavaObject = Button
Dim event As Object = JO.CreateEvent("android.view.View.OnFocusChangeListener",EventName,False)
JO.RunMethod("setOnFocusChangeListener",Array As Object(event))
End Sub
Sub Help_Event(MethodName As String, Args() As Object)
Log("Button has focus: " & Args(1)) 'Args(1) is True if button has focus, false otherwise.
End Sub
SetUpOnFocusListener(Help,"Help")
'This code will be applied to the manifest file during compilation.
'You do not need to modify it in most cases.
'See this link for for more information: http://www.b4x.com/forum/showthread.php?p=78136
AddManifestText(
<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="14"/>
<uses-feature android:name="android.hardware.gamepad" android:required="false"/>
<uses-feature android:name="android.hardware.touchscreen" android:required="false"/>
<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT"/>
<supports-screens android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:anyDensity="true"/>)
'SetApplicationAttribute(android:hardwareAccelerated, "false")
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
'End of default text.
AddPermission(com.android.launcher.permission.UNINSTALL_SHORTCUT)
'SetApplicationAttribute(android:theme, "@android:style/Theme.Holo")
#Region Project Attributes
#FullScreen: False
#IncludeTitle: True
#ApplicationLabel: My App
#VersionCode: 1
#VersionName:
#SupportedOrientations: unspecified
#CanInstallToExternalStorage: False
'#DebuggerForceStandardAssets: true
#End Region
#Region Activity Attributes
#FullScreen: False
#IncludeTitle: True
#End Region
Sub Process_Globals
End Sub
Public Sub CreateButtonColor(FocusedColor As Int, EnabledColor As Int, DisabledColor As Int, PressedColor As Int) As StateListDrawable
Dim res As StateListDrawable
res.Initialize
Dim drwFocusedColor, drwEnabledColor, drwDisabledColor, drwPressedColor As ColorDrawable
'drwFocusedColor.Initialize2(FocusedColor, 5, 0, Colors.LightGray) 'border roundness, thickness, and color on Android TV
'drwEnabledColor.Initialize2(EnabledColor, 5, 0, Colors.DarkGray)
'drwDisabledColor.Initialize2(DisabledColor, 5, 0, Colors.White)
'drwPressedColor.Initialize2(PressedColor, 5, 0, Colors.Black)
drwFocusedColor.Initialize2(FocusedColor, 0, 1, Colors.RGB(110,110,110))
drwEnabledColor.Initialize2(EnabledColor, 0, 0, Colors.RGB(110,110,110))
drwDisabledColor.Initialize2(DisabledColor, 0, 0, Colors.RGB(110,110,110))
drwPressedColor.Initialize2(PressedColor, 0, 0, Colors.RGB(110,110,110))
res.AddState(res.State_Focused, drwFocusedColor)
res.AddState(res.State_Pressed, drwPressedColor)
res.AddState(res.State_Enabled, drwEnabledColor)
res.AddState(res.State_Disabled, drwDisabledColor)
res.AddCatchAllState(drwEnabledColor)
Return res
End Sub
Sub Globals
Private CreateShortcut As Button
Private Help As Button
Private Exit As Button
Private Panel1 As Panel
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("myappmain")
Dim re1 As RippleView 'RippleEffect for buttons that stay on same screen
re1.Initialize(CreateShortcut, Colors.Blue, 300, False) 'True will center the ripple, False will start the ripple where tapped
Dim re2 As RippleView
re2.Initialize(Help, Colors.Blue, 300, False)
Dim re3 As RippleView
re3.Initialize(Panel1, Colors.Green, 300, False)
'ExitB.Background = CreateButtonColor(Colors.RGB(0,51,102), Colors.RGB(0,33,88), Colors.White, Colors.RGB(0,76,153)) '<--from Public Subs
'Help.Background = CreateButtonColor(Colors.LightGray, Colors.DarkGray, Colors.White, Colors.Black) '<--from Public Subs
'Help.Background = CreateButtonColor(Colors.RGB(96,96,96), Colors.DarkGray, Colors.White, Colors.RGB(120,120,120)) '<--from Public Subs
Help.Background = CreateButtonColor(Colors.RGB(0,51,102), Colors.RGB(0,33,88), Colors.White, Colors.RGB(0,76,153)) '<--from Public Subs
CreateShortcut.Background = CreateButtonColor(Colors.RGB(0,51,102), Colors.RGB(0,33,88), Colors.White, Colors.RGB(0,76,153)) '<--from Public Subs
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub Help_Click
StartActivity("Help1")
End Sub
Sub Exit_Click
ExitApplication
End Sub
Sub CreateShortCut_Click
Dim shortcutIntent As Intent
shortcutIntent.Initialize("", "")
shortcutIntent.SetComponent("My.App/.main") '<------change My.App for your own app file name here, like "My.Game", look into Tools, Build Configurations for your app's name
Dim in As Intent
in.Initialize("", "")
in.PutExtra("duplicate",False)
in.PutExtra("android.intent.extra.shortcut.INTENT", shortcutIntent)
in.PutExtra("android.intent.extra.shortcut.NAME", "My App") '<-----Type here the name of the shortcut, "My App" for "Your App"
in.PutExtra("android.intent.extra.shortcut.ICON", LoadBitmap(File.DirAssets, "color01.png")) '<----your app image here, "color01.png" for "yourpic.png"
in.Action = "com.android.launcher.action.INSTALL_SHORTCUT"
Dim p As Phone
p.SendBroadcastIntent(in)
DoEvents
End Sub
Dim states(4) As Int
states(0) = stdBitmap.state_Focused
states(1) = stdBitmap.state_Enabled
states(2) = -stdBitmap.state_Pressed
states(3) = -stdBitmap.state_Disabled
stdBitmap.addState2(states, bdwFocused)
Dim states(2) As Int
states(0) = stdBitmap.state_Enabled
states(1) = -stdBitmap.state_Pressed
stdBitmap.addState2(states, bdwEnabled)
Dim states(1) As Int
states(0) = stdBitmap.state_Pressed
stdBitmap.addState2(states, bdwPressed)
btn.background=stdBitmap
Sub Buttondraw(btn As Button,btntxt As String,fns As Int,cl As Int)
Dim bx,by As Int
Dim bdwFocused As BitmapDrawable
Dim bdwEnabled As BitmapDrawable
Dim bdwPressed As BitmapDrawable
Dim bdwDisabled As BitmapDrawable
buttonlabel.Text=btntxt
buttonlabel.TextSize=fns
Dim Height_, Width_ As Int
buttonlabel.Width = -2
buttonlabel.Height = -2
DoEvents
obj.Target = buttonlabel
Width_ = obj.RunMethod("getWidth")
Height_ = obj.RunMethod("getHeight")
buttonpic.Width=btn.Width
buttonpic.Height=btn.Height
'================This will show text on the button
' buttonpic.Bitmap = LoadBitmap(File.Dirassets,"Brushed_Steel_Blue_01.jpg") '?????? Not needed
c.Initialize(buttonpic)
bx=(btn.Width-Width_)/2
by=(btn.Height+fns)/2
c.DrawText(btntxt,bx,by,myfont, fns, cl, "LEFT")
'================
'This section inludes: FOCUSED, ENABLED, PRESSED, & DISABLED
bdwEnabled.Initialize(buttonpic.Bitmap) 'It will not work without this code HERE.
Dim Focused As BitmapDrawable
buttonpic.Bitmap = LoadBitmap(File.Dirassets,"Metal_Red_Brushed_01_1.jpg")
c.Initialize(buttonpic)
c.DrawText(btntxt,bx,by,myfont, fns, cl, "LEFT")
bdwFocused.Initialize(buttonpic.Bitmap)
bdwEnabled.Initialize(buttonpic.Bitmap) 'It will not work without this code HERE.
Dim bdwEnabled As BitmapDrawable
buttonpic.Bitmap = LoadBitmap(File.Dirassets,"Brushed_Copper_06.jpg")
c.Initialize(buttonpic)
c.DrawText(btntxt,bx,by,myfont, fns, cl, "LEFT")
bdwEnabled.Initialize(buttonpic.Bitmap)
Dim bdwPressed As BitmapDrawable
buttonpic.Bitmap = LoadBitmap(File.Dirassets,"Brushed_Steel_Blue_01.jpg")
c.Initialize(buttonpic)
c.DrawText(btntxt,bx,by,myfont, fns, cl, "LEFT")
bdwPressed.Initialize(buttonpic.Bitmap)
Dim bdwDisabled As BitmapDrawable
buttonpic.Bitmap = LoadBitmap(File.Dirassets,"Brushed_Steel_Black_09.jpg")
c.Initialize(buttonpic)
c.DrawText(btntxt,bx,by,myfont, fns, Colors.Gray, "LEFT")
bdwDisabled.Initialize(buttonpic.Bitmap)
Dim stdBitmap As StateListDrawable
stdBitmap.Initialize
Dim states(4) As Int
states(0) = stdBitmap.state_Focused
states(1) = stdBitmap.state_Enabled
states(2) = -stdBitmap.state_Pressed
states(3) = -stdBitmap.state_Disabled
stdBitmap.addState2(states, bdwFocused)
Dim states(2) As Int
states(0) = stdBitmap.state_Enabled
states(1) = -stdBitmap.state_Pressed
stdBitmap.addState2(states, bdwEnabled)
Dim states(1) As Int
states(0) = stdBitmap.state_Pressed
stdBitmap.addState2(states, bdwPressed)
btn.background=stdBitmap
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("myappmain")
'==========This section calls the "Sub BottonDraw..."
myfont = Typeface.LoadFromAssets("ardelaney.ttf")
buttonpic.Left=3000
buttonlabel.Left=3000
Buttondraw(Button1,"",18,Colors.Black) 'NOTE: This button's tile was added in the designer as an alternative
Buttondraw(Button2,"B2",18,Colors.Black)
'Usage : Buttondraw(Button_name ,Button Text,Font size,Font color)
'==========
End Sub
Sub Exit_Click
ExitApplication
End Sub
Public Sub CreateButtonColor(FocusedColor As Int, EnabledColor As Int, DisabledColor As Int, PressedColor As Int) As StateListDrawable
Dim res As StateListDrawable
res.Initialize
Dim drwFocusedColor, drwEnabledColor, drwDisabledColor, drwPressedColor As ColorDrawable
'drwFocusedColor.Initialize2(FocusedColor, 5, 0, Colors.LightGray) 'border roundness, thickness, and color on Android TV
'drwEnabledColor.Initialize2(EnabledColor, 5, 0, Colors.DarkGray)
'drwDisabledColor.Initialize2(DisabledColor, 5, 0, Colors.White)
'drwPressedColor.Initialize2(PressedColor, 5, 0, Colors.Black)
drwFocusedColor.Initialize2(FocusedColor, 0, 1, Colors.White) 'border roundness, thickness, and color on Android TV
drwEnabledColor.Initialize2(EnabledColor, 0, 0, Colors.RGB(110,110,110))
drwDisabledColor.Initialize2(DisabledColor, 0, 0, Colors.RGB(110,110,110))
drwPressedColor.Initialize2(PressedColor, 0, 0, Colors.RGB(110,110,110))
res.AddState(res.State_Focused, drwFocusedColor)
res.AddState(res.State_Pressed, drwPressedColor)
res.AddState(res.State_Enabled, drwEnabledColor)
res.AddState(res.State_Disabled, drwDisabledColor)
res.AddCatchAllState(drwEnabledColor)
Return res
End Sub
Sub Buttondraw(btn As Button,btntxt As String,fns As Int,cl As Int)
Dim bx,by As Int
Dim bdwFocused As BitmapDrawable
Dim bdwEnabled As BitmapDrawable
Dim bdwPressed As BitmapDrawable
Dim bdwDisabled As BitmapDrawable
buttonlabel.Text=btntxt
buttonlabel.TextSize=fns
Dim Height_, Width_ As Int
buttonlabel.Width = -2
buttonlabel.Height = -2
DoEvents
obj.Target = buttonlabel
Width_ = obj.RunMethod("getWidth")
Height_ = obj.RunMethod("getHeight")
buttonpic.Width=btn.Width
buttonpic.Height=btn.Height
'=========== This will show text on the button ===============================
' buttonpic.Bitmap = LoadBitmap(File.Dirassets,"Brushed_Steel_Blue_01.jpg") '?????? Not needed
c.Initialize(buttonpic)
bx=(btn.Width-Width_)/2
by=(btn.Height+fns)/2
c.DrawText(btntxt,bx,by,myfont, fns, cl, "LEFT")
'=============================================================================
'=========== This section inludes: FOCUSED, ENABLED, PRESSED, & DISABLED =====
bdwEnabled.Initialize(buttonpic.Bitmap) 'It will not work without this code HERE.
Dim Focused As BitmapDrawable
buttonpic.Bitmap = LoadBitmap(File.Dirassets,"Metal_Copper_Brown_Brushed_07_Focused.jpg")
c.Initialize(buttonpic)
c.DrawText(btntxt,bx,by,myfont, fns, cl, "LEFT")
bdwFocused.Initialize(buttonpic.Bitmap)
bdwEnabled.Initialize(buttonpic.Bitmap) 'It will not work without this code HERE.
Dim bdwEnabled As BitmapDrawable
buttonpic.Bitmap = LoadBitmap(File.Dirassets,"Metal_Copper_Brown_Brushed_01_Enabled.jpg")
c.Initialize(buttonpic)
c.DrawText(btntxt,bx,by,myfont, fns, cl, "LEFT")
bdwEnabled.Initialize(buttonpic.Bitmap)
Dim bdwPressed As BitmapDrawable
buttonpic.Bitmap = LoadBitmap(File.Dirassets,"Metal_Steel_LightBlue_Brushed_01_Pressed.jpg")
c.Initialize(buttonpic)
c.DrawText(btntxt,bx,by,myfont, fns, cl, "LEFT")
bdwPressed.Initialize(buttonpic.Bitmap)
Dim bdwDisabled As BitmapDrawable
buttonpic.Bitmap = LoadBitmap(File.Dirassets,"Metal_Steel_Brushed_08_Disabled.jpg")
c.Initialize(buttonpic)
c.DrawText(btntxt,bx,by,myfont, fns, Colors.Gray, "LEFT")
bdwDisabled.Initialize(buttonpic.Bitmap)
Dim stdBitmap As StateListDrawable
stdBitmap.Initialize
Dim states(4) As Int
states(0) = stdBitmap.state_Focused
states(1) = stdBitmap.state_Enabled
states(2) = -stdBitmap.state_Pressed
states(3) = -stdBitmap.state_Disabled
stdBitmap.addState2(states, bdwFocused)
Dim states(2) As Int
states(0) = stdBitmap.state_Enabled
states(1) = -stdBitmap.state_Pressed
stdBitmap.addState2(states, bdwEnabled)
Dim states(1) As Int
states(0) = stdBitmap.state_Pressed
stdBitmap.addState2(states, bdwPressed)
btn.background=stdBitmap
'=============================================================================
End Sub
'This code will be applied to the manifest file during compilation.
'You do not need to modify it in most cases.
'See this link for for more information: http://www.b4x.com/forum/showthread.php?p=78136
AddManifestText(
<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="14"/>
<uses-feature android:name="android.hardware.gamepad" android:required="false"/>
<uses-feature android:name="android.hardware.touchscreen" android:required="false"/>
<uses-feature android:name="android.software.leanback" android:required="false" />
<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT"/>
<supports-screens android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:anyDensity="true"
android:xlargeScreens="true"/>)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
SetApplicationAttribute(android:theme, "@android:style/Theme.Holo")
SetApplicationAttribute(android:banner, "@drawable/banner")
AddActivityText(TvActivity,
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LEANBACK_LAUNCHER" />
</intent-filter>)
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?