I have created a form in the designer and linked a ListView to one of the button, however the ListView overlaps the whole application and sticks to the screen can someone have a look at my code and explain to me how i can fix that? I want the ListView to appear on its own screen.
B4X:
Sub Process_Globals
Private currentPage As Int
End Sub
Sub Globals
Dim mFragment As MapFragment
Dim gmap As GoogleMap
Dim MapPanel As Panel
Dim bar As StdActionBar
Dim vp As StdViewPager
Dim ListView1 As ListView
End Sub
Sub Activity_Create(FirstTime As Boolean)
MapPanel.Initialize("")
bar.Initialize("bar")
bar.NavigationMode = bar.NAVIGATION_MODE_TABS
Dim h As Int = CalculateHeight(True, False)
vp.Initialize("vp", 3, 100%x, h)
MapPanel.Initialize("")
Activity.AddView(vp.AsView, 0, 0, 100%x, h)
vp.Panels(0).AddView(MapPanel,0, 0, 100%x, h)
vp.Panels(1).Color = Colors.Red
vp.Panels(2).LoadLayout("0")
bar.AddTab("Map")
bar.AddTab("Red panel")
bar.AddTab("Equipment")
'Google Maps
If mFragment.IsGooglePlayServicesAvailable = False Then
ToastMessageShow("Google Play services not available.", True)
Else
mFragment.Initialize("Map", MapPanel)
End If
'ListView
End Sub
Sub CalculateHeight (TabsMode As Boolean, SplitEnabled As Boolean) As Int
If 100%x >= 480dip Then
Return 100%y
Else
Dim fix As Int
If TabsMode Then fix = 48dip
If SplitEnabled Then fix = fix + 48dip
Return 100%y - fix
End If
End Sub
Sub VP_PageSelected (Position As Int)
If bar.SelectedIndex <> Position Then bar.SelectedIndex = Position
End Sub
Sub bar_TabChanged(Index As Int, STab As StdTab)
If vp.currentPage <> Index Then vp.ScrollTo(Index, False)
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
currentPage = bar.SelectedIndex
End Sub
'Google Maps
Sub Map_Ready
Log("map ready")
gmap = mFragment.GetMap
If gmap.IsInitialized = False Then
ToastMessageShow("Error initializing map.", True)
Else
gmap.AddMarker(53.544133, -2.605544, "Royce's")
Dim cp As CameraPosition
cp.Initialize(53.544133, -2.605544, gmap.CameraPosition.Zoom)
gmap.AnimateCamera(cp)
End If
End Sub
Sub Machine_Button_Click
ListView1.Initialize("ListView1")
Dim GD As GradientDrawable
GD.Initialize("TR_BL", Array As Int(Colors.White, Colors.LightGray))
Activity.Background = GD
ListView1.ScrollingBackgroundColor = Colors.Transparent
Dim Bitmap1 As Bitmap
Bitmap1.Initialize(File.DirAssets, "Pic1.jpg")
Dim Bitmap2 As Bitmap
Bitmap2.Initialize(File.DirAssets, "Pic2.jpg")
Dim Bitmap3 As Bitmap
Bitmap3.Initialize(File.DirAssets, "Pic3.jpg")
Dim Bitmap4 As Bitmap
Bitmap4.Initialize(File.DirAssets, "Pic4.jpg")
Dim Bitmap5 As Bitmap
Bitmap5.Initialize(File.DirAssets, "Pic5.jpg")
Dim Bitmap6 As Bitmap
Bitmap6.Initialize(File.DirAssets, "R.png")
ListView1.TwoLinesAndBitmap.ItemHeight = 160dip
ListView1.TwoLinesAndBitmap.ImageView.Height = 150dip
ListView1.TwoLinesAndBitmap.ImageView.Width = 150dip
ListView1.TwoLinesAndBitmap.Label.Gravity = Gravity.CENTER
ListView1.TwoLinesAndBitmap.Label.TextColor = Colors.Blue
ListView1.TwoLinesAndBitmap.SecondLabel.Gravity = Gravity.CENTER
ListView1.TwoLinesAndBitmap.SecondLabel.TextColor = Colors.Cyan
ListView1.SingleLineLayout.ItemHeight = 100dip
ListView1.SingleLineLayout.Label.TextSize = 20
ListView1.SingleLineLayout.Label.TextColor = Colors.Blue
ListView1.SingleLineLayout.Label.Gravity = Gravity.CENTER
ListView1.FastScrollEnabled = True
ListView1.AddTwoLinesAndBitmap("Machine #1", "This is the second line.", Bitmap1)
ListView1.AddTwoLinesAndBitmap("Machine #2", "This is the second line.", Bitmap2)
ListView1.AddTwoLinesAndBitmap("Machine #3", "This is the second line.", Bitmap3)
ListView1.AddTwoLinesAndBitmap("Machine #4", "This is the second line.", Bitmap4)
ListView1.AddTwoLinesAndBitmap("Machine #5", "This is the second line.", Bitmap5)
Activity.AddView(ListView1, 0, 0, 100%x, 100%y)
End Sub
Sub Free_Weight_Button_Click
End Sub
Sub Cardio_Button_Click
End Sub