Membuat Generate layout interface menggunakan Basic4android
hello sobat bloger,
saat ini, begitu banyak Platform android yang bisa kita gunakan untuk membuat aplikasi berbasis android, salah satunya Basic4android dan masih banyak lagi diantaranya android studio, xamarin,B4j,B4i, cordova.
kita tidak akan membahas satu persatu platform, kita fokus ke Basic4android sobat blogger, okey kalau begitu kita mulai saja pembahasan untuk ini yah,
untuk memulai tutorial ini semoga sobat bloger sudah tahu Basic4android sebelumnya yah,
pertama : kita menyiapkan aplikasinya
kedua : mari kita koding.., berikut adalah source codenya
< source code />
#Region Project Attributes
#ApplicationLabel: Messenger
#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
Sub Process_Globals
End Sub
Sub Globals
Dim Pchat As ScrollView
End Sub
Sub Activity_Create(FirstTime As Boolean)
End Sub
Sub Activity_KeyPress (KeyCode As Int) As Boolean 'Return True to consume the event
If KeyCode = KeyCodes.KEYCODE_BACK Then
Return True
End If
Return False
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub Add_Conversation (leftChat As Boolean, name As String, message As String, tanggal As String)
Try
Dim lb1,dt1 As Label
Dim str As String
Dim pnl,pnldt1,pnlutama As Panel
pnl.Initialize("pnl")
pnldt1.Initialize("pnldt1")
pnlutama.Initialize("pnlutama")
Dim c, d As ColorDrawable
c.Initialize2(Colors.rgb(128, 214, 214),5dip, 1dip,Colors.Yellow)
d.Initialize2(Colors.White,5dip, 1dip,Colors.Yellow)
pnl.Background = c
pnldt1.Background = d
pnlutama.Color = Colors.White
dt1.Initialize("dt1")
dt1.Text = tanggal
dt1.Textcolor = Colors.Magenta
dt1.TextSize = 8
dt1.Gravity = Gravity.LEFT
lb1.Initialize("lb1")
lb1.TextSize = 14
lb1.TextColor = Colors.Blue
lb1.Gravity = Gravity.LEFT
lb1.Text = message
lb1.Padding = Array As Int(5dip,2dip,5dip,0dip)
str = lb1.Text
Dim n As Int = str.Length + 10
Dim nh, dk As String
If n >= 50 Then
dk = 250dip
nh = 80dip
pnldt1.AddView(dt1,3dip, 5dip, 100dip, 20dip)
else If n < 50 Then
dk = n & 0dip
nh = 40dip
pnldt1.AddView(dt1,3dip, 5dip, 100dip, 20dip)
End If
counter = counter + nh + 5
Pchat.Panel.Height = counter + nh
pnl.AddView(lb1,5dip, 0dip, dk, nh)
If leftChat = True Then
pnlutama.AddView(pnl, 5dip, 0dip, dk, nh )
pnlutama.AddView(pnldt1, dk + 20dip, 10dip, 80dip, 20dip )
Pchat.Panel.AddView(pnlutama, 0dip, counter - nh, 100%x, nh + 10dip )
Else
pnlutama.AddView(pnl, 100%x - dk - 5, 0dip, dk, nh )
pnlutama.AddView(pnldt1, 100%x - (dk + 80dip + 20dip), 10dip, 80dip, 20dip )
Pchat.Panel.AddView(pnlutama, 0dip, counter - nh, 100%x, nh + 10dip)
End If
Pchat.ScrollPosition = Pchat.Panel.Height
DoEvents
Pchat.ScrollPosition = Pchat.Panel.Height
DoEvents
Catch
Msgbox(LastException, "Info")
End Try
End Sub
coding di atas nanti akan generate seperti gambar, bila kurang jelas tinggalkan komentar yah
saat ini, begitu banyak Platform android yang bisa kita gunakan untuk membuat aplikasi berbasis android, salah satunya Basic4android dan masih banyak lagi diantaranya android studio, xamarin,B4j,B4i, cordova.
kita tidak akan membahas satu persatu platform, kita fokus ke Basic4android sobat blogger, okey kalau begitu kita mulai saja pembahasan untuk ini yah,
untuk memulai tutorial ini semoga sobat bloger sudah tahu Basic4android sebelumnya yah,
pertama : kita menyiapkan aplikasinya
kedua : mari kita koding.., berikut adalah source codenya
< source code />
#Region Project Attributes
#ApplicationLabel: Messenger
#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
Sub Process_Globals
End Sub
Sub Globals
Dim Pchat As ScrollView
End Sub
Sub Activity_Create(FirstTime As Boolean)
End Sub
Sub Activity_KeyPress (KeyCode As Int) As Boolean 'Return True to consume the event
If KeyCode = KeyCodes.KEYCODE_BACK Then
Return True
End If
Return False
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub Add_Conversation (leftChat As Boolean, name As String, message As String, tanggal As String)
Try
Dim lb1,dt1 As Label
Dim str As String
Dim pnl,pnldt1,pnlutama As Panel
pnl.Initialize("pnl")
pnldt1.Initialize("pnldt1")
pnlutama.Initialize("pnlutama")
Dim c, d As ColorDrawable
c.Initialize2(Colors.rgb(128, 214, 214),5dip, 1dip,Colors.Yellow)
d.Initialize2(Colors.White,5dip, 1dip,Colors.Yellow)
pnl.Background = c
pnldt1.Background = d
pnlutama.Color = Colors.White
dt1.Initialize("dt1")
dt1.Text = tanggal
dt1.Textcolor = Colors.Magenta
dt1.TextSize = 8
dt1.Gravity = Gravity.LEFT
lb1.Initialize("lb1")
lb1.TextSize = 14
lb1.TextColor = Colors.Blue
lb1.Gravity = Gravity.LEFT
lb1.Text = message
lb1.Padding = Array As Int(5dip,2dip,5dip,0dip)
str = lb1.Text
Dim n As Int = str.Length + 10
Dim nh, dk As String
If n >= 50 Then
dk = 250dip
nh = 80dip
pnldt1.AddView(dt1,3dip, 5dip, 100dip, 20dip)
else If n < 50 Then
dk = n & 0dip
nh = 40dip
pnldt1.AddView(dt1,3dip, 5dip, 100dip, 20dip)
End If
counter = counter + nh + 5
Pchat.Panel.Height = counter + nh
pnl.AddView(lb1,5dip, 0dip, dk, nh)
If leftChat = True Then
pnlutama.AddView(pnl, 5dip, 0dip, dk, nh )
pnlutama.AddView(pnldt1, dk + 20dip, 10dip, 80dip, 20dip )
Pchat.Panel.AddView(pnlutama, 0dip, counter - nh, 100%x, nh + 10dip )
Else
pnlutama.AddView(pnl, 100%x - dk - 5, 0dip, dk, nh )
pnlutama.AddView(pnldt1, 100%x - (dk + 80dip + 20dip), 10dip, 80dip, 20dip )
Pchat.Panel.AddView(pnlutama, 0dip, counter - nh, 100%x, nh + 10dip)
End If
Pchat.ScrollPosition = Pchat.Panel.Height
DoEvents
Pchat.ScrollPosition = Pchat.Panel.Height
DoEvents
Catch
Msgbox(LastException, "Info")
End Try
End Sub
coding di atas nanti akan generate seperti gambar, bila kurang jelas tinggalkan komentar yah
Komentar
Posting Komentar