Hi,
I'm new to building apps and it's been a fairly steep learning curve so far.
The code below (apologies for its crudeness), for a listview with 5 buttons, compiles without errors.
If I download it onto my Samsung S2, it works perfectly.
However, on a new Samsung Galaxy Mini, the listview doesn't appear...only the logo and lines:
line1=("We are a business......")
line2=("Our systems will........")
are shown.
Another issue is that on my Samsumg S2, if the listview is slightly longer than the height of the screen and I scroll down to the last button, it immediately "bounces" back up so that I can't click on the last one.
If someone could point me in the right direction I'd be more than grateful.
Many thanks
I'm new to building apps and it's been a fairly steep learning curve so far.
The code below (apologies for its crudeness), for a listview with 5 buttons, compiles without errors.
B4X:
'Activity module
Sub Process_Globals
Dim hc As HttpClient
Dim Phone1 As PhoneCalls
Dim Message As Email
Dim EmailAddress As String
End Sub
Sub Globals
Dim ListView1 As ListView
Dim ImageView1 As ImageView
Dim ImageView2 As ImageView
Dim Label1 As Label
Dim lblMainText As Label
Dim lblPhone As Label
Dim lblEmail As Label
Dim lblWebsite As Label
End Sub
Sub Activity_Create(FirstTime As Boolean)
If FirstTime Then
hc.Initialize("hc")
End If
Activity.LoadLayout("1")
CallSub ("",HomePage)
End Sub
Sub HomePage
'Wipe the screen first
ListView1.Clear
Label1.visible=True
Label1.Text=""
lblMainText.Visible=False
lblPhone.Visible=False
lblEmail.Visible=False
lblWebsite.Visible=False
ImageView2.Visible = False
ListView1.Initialize("ListView1")
ListView1.SingleLineLayout.ItemHeight = 150dip
ListView1.SingleLineLayout.Label.TextSize = 12
ListView1.SingleLineLayout.Label.TextColor = Colors.DarkGray
ListView1.SingleLineLayout.Label.Gravity = Gravity.LEFT
ListView1.ScrollingBackgroundColor = Colors.Transparent
ListView1.Color=Colors.Transparent
Dim line1, line2 As String
line1=("We are a business......")
line2=("Our systems will........")
Label1.Text = line1 & CRLF & CRLF & line2
Label1.TextColor = Colors.DarkGray
Label1.TextSize = 12
Label1.Gravity = Gravity.TOP
ListView1.AddTwoLinesAndBitmap2("ABOUT US","Tap here to see who we are",LoadBitmap(File.DirAssets,"about.png"),"about")
ListView1.TwoLinesAndBitmap.SecondLabel.TextSize = 10
ListView1.AddTwoLinesAndBitmap2("SERVICES","Tap here to see what we do",LoadBitmap(File.DirAssets,"services.png"),"services")
ListView1.TwoLinesAndBitmap.SecondLabel.TextSize = 10
ListView1.AddTwoLinesAndBitmap2("BENEFITS","Tap here to see the benefits for you",LoadBitmap(File.DirAssets,"benefits.png"),"benefits")
ListView1.TwoLinesAndBitmap.SecondLabel.TextSize = 10
ListView1.AddTwoLinesAndBitmap2("CONTACT US","Tap here to see our contact details",LoadBitmap(File.DirAssets,"contact.png"),"contact")
ListView1.TwoLinesAndBitmap.SecondLabel.TextSize = 10
ListView1.AddTwoLinesAndBitmap2("TESTIMONIALS","Tap here to see what our customers say",LoadBitmap(File.DirAssets,"testimonials.png"),"testimonials")
ListView1.TwoLinesAndBitmap.SecondLabel.TextSize = 10
Activity.AddView(ListView1, 13, 350, 90%x, 100%y)
End Sub
Sub ListView1_ItemClick (Position As Int, Value As Object)
Dim currentpage As String
currentpage=Value
Select currentpage
Case "about"
ListView1.Clear
Label1.Visible=False
lblMainText.Visible=True
Dim line1, line2, line3 As String
line1=("We are a company that.........")
line2=("Previously our owner was...........")
line3=("He obtained his degree in..........")
lblMainText.Text = line1 & CRLF & CRLF & line2 & CRLF & CRLF & line3
lblMainText.TextColor = Colors.DarkGray
lblMainText.TextSize = 12
lblMainText.Gravity = Gravity.TOP
ImageView2.Visible = True
Dim aboutusimage As BitmapDrawable
aboutusimage.Initialize(LoadBitmap(File.DirAssets,"about.png"))
aboutusimage.Gravity = Gravity.FILL
ImageView2.Top = 450
ImageView2.Background = aboutusimage
Case "services"
ListView1.Clear
Label1.Visible=False
lblMainText.Visible=True
Dim line1 As String
line1=("Text goes here...")
lblMainText.Text = line1
lblMainText.TextColor = Colors.DarkGray
lblMainText.TextSize = 12
lblMainText.Gravity = Gravity.TOP
ImageView2.Visible = True
Dim testimonialsimage As BitmapDrawable
testimonialsimage.Initialize(LoadBitmap(File.DirAssets,"services.png"))
testimonialsimage.Gravity = Gravity.FILL
ImageView2.Top = 600
ImageView2.Background = testimonialsimage
Case "benefits"
ListView1.Clear
Label1.Visible=False
lblMainText.Visible=True
Dim line1 As String
line1=("Our systems benefit small, medium and large businesses in numerous ways:")
lblMainText.Text = line1
lblMainText.TextColor = Colors.DarkGray
lblMainText.TextSize = 12
lblMainText.Gravity = Gravity.TOP
ImageView2.Visible = True
Dim benefitsimage As BitmapDrawable
benefitsimage.Initialize(LoadBitmap(File.DirAssets,"benefits.png"))
benefitsimage.Gravity = Gravity.FILL
ImageView2.Top = 450
ImageView2.Background = benefitsimage
Case "contact"
ListView1.Clear
Label1.Visible=False
lblMainText.Visible=True
lblPhone.Visible=True
lblEmail.Visible=True
lblWebsite.Visible=True
lblMainText.Text=("Address: Main Street ")
lblPhone.Text=("Phone: 012 123456 (tap phone number to call)")
lblEmail.Text=("Email: mailto:[email protected]")
Dim Obj1 As Reflector
lblEmail.Text = "Email: [email protected]"
Obj1.Target = Obj1.CreateObject("android.text.util.Linkify")
Dim args(2) As Object
Dim types(2) As String
args(0) = lblEmail
types(0) = "android.widget.TextView"
args(1) = 15
types(1) = "java.lang.int"
Obj1.RunMethod4("addLinks", args, types)
Dim Obj2 As Reflector
lblWebsite.Text = "Website: http://www.somewhere.com"
Obj2.Target = Obj2.CreateObject("android.text.util.Linkify")
Dim args(2) As Object
Dim types(2) As String
args(0) = lblWebsite
types(0) = "android.widget.TextView"
args(1) = 15
types(1) = "java.lang.int"
Obj2.RunMethod4("addLinks", args, types)
lblMainText.TextColor = Colors.DarkGray
lblMainText.TextSize = 12
lblMainText.Gravity = Gravity.TOP
lblPhone.TextColor = Colors.DarkGray
lblPhone.TextSize = 12
lblPhone.Gravity = Gravity.TOP
lblEmail.TextColor = Colors.DarkGray
lblEmail.TextSize = 12
lblEmail.Gravity = Gravity.TOP
lblWebsite.TextColor = Colors.DarkGray
lblWebsite.TextSize = 12
lblWebsite.Gravity = Gravity.TOP
ImageView2.Visible = True
Dim contactimage As BitmapDrawable
contactimage.Initialize(LoadBitmap(File.DirAssets,"contact.png"))
contactimage.Gravity = Gravity.FILL
ImageView2.Top = 350
ImageView2.Background = contactimage
Case "testimonials"
ListView1.Clear
Label1.Visible=False
lblMainText.Visible=True
Dim line1 As String
line1=("'Our previous invoicing system.......'")
lblMainText.Text = line1
lblMainText.TextColor = Colors.DarkGray
lblMainText.TextSize = 12
lblMainText.Gravity = Gravity.TOP
ImageView2.Visible = True
Dim testimonialsimage As BitmapDrawable
testimonialsimage.Initialize(LoadBitmap(File.DirAssets,"testimonials.png"))
testimonialsimage.Gravity = Gravity.FILL
ImageView2.Top = 600
ImageView2.Background = testimonialsimage
End Select
End Sub
Sub lblPhone_Click
StartActivity(Phone1.Call("00353012123456"))
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub Activity_Keypress(KeyCode As Int) As Boolean
If KeyCode = KeyCodes.KEYCODE_BACK Then
CallSub ("",HomePage)
Return True
End If
End Sub
If I download it onto my Samsung S2, it works perfectly.
However, on a new Samsung Galaxy Mini, the listview doesn't appear...only the logo and lines:
line1=("We are a business......")
line2=("Our systems will........")
are shown.
Another issue is that on my Samsumg S2, if the listview is slightly longer than the height of the screen and I scroll down to the last button, it immediately "bounces" back up so that I can't click on the last one.
If someone could point me in the right direction I'd be more than grateful.
Many thanks