iOS Question Converting B4a to B4i with Listview

DeclanOK

Member
Licensed User
I am converting a successful B4A app to B4i. I am trying to use TableView and then as I couldn't I started looking at CustomListView. I simply want to show a list and click on it and read the value

What method do I use to get the clicked on a row in the table

Here is my B4A code. I have spent the weekend going through docs and am no smarter

Any recommendations very useful
--------------------------------------------------------------------------------------------------------
B4X:
Sub Globals
 'These global variables will be redeclared each time the activity is created.
 'These variables can only be accessed from this module.
 
 Private SubjectList As ListView
 
End Sub
Sub Activity_Create(FirstTime As Boolean)
 'Do not forget to load the layout file created with the visual designer. For example:
   If File.Exists(File.DirInternal, "Index.db") = False Then
       
   File.Copy(File.DirAssets, "Index.db", File.DirInternal, "Index.db")
 
   End If ' goes with above just did this To ensure always loads new database
 
 
 Activity.Color = Colors.Black
 Activity.TitleColor= Colors.White
 Activity.LoadLayout("StartUp")
 Activity.Title = "ABC Medical Notes (2200+ Notes)"
 FillList
 
 If FirstTime = True Then Msgbox("Now over 2200 Searchable Notes for Exam Success. Please spread the word as more users means more content and updates and no adverts. Please give 5 stars. The information contained is for study and exams and not for patient management, Please use local guidelines and enlist senior support.", "ABC Medical Notes Pro")
 
End Sub
Sub FillList
 SetLVHeights4TextSize(SubjectList, True, 22, 22 , 5)
 SubjectList.Color=Colors.White
 SubjectList.SingleLineLayout.Label.TextSize = 22
 SubjectList.SingleLineLayout.Label.TextColor = Colors.Black
 Dim gd As GradientDrawable
 gd.Initialize("BOTTOM_TOP", Array As Int (Colors.white, Colors.ARGB(249, 249,249,249)))
 SubjectList.SingleLineLayout.Background = gd
 SubjectList.AddSingleLine("All entries...")
 
 SubjectList.AddSingleLine("Anatomy")
 SubjectList.AddSingleLine("Antibiotic guidance")
 SubjectList.AddSingleLine("Basic Science")
 SubjectList.AddSingleLine("Cardiology")
 SubjectList.AddSingleLine("Clinical Skills")
 SubjectList.AddSingleLine("Critical Care")
 SubjectList.AddSingleLine("Dermatology")
 SubjectList.AddSingleLine("Drugs")
 SubjectList.AddSingleLine("Electrocardiogram")
 SubjectList.AddSingleLine("Emergency Medicine")
 SubjectList.AddSingleLine("Endocrinology")
 SubjectList.AddSingleLine("ENT")
 SubjectList.AddSingleLine("Examination")
 SubjectList.AddSingleLine("Gastroenterology")
 SubjectList.AddSingleLine("General Practice")
 SubjectList.AddSingleLine("General Information")
 SubjectList.AddSingleLine("Genetics")
 SubjectList.AddSingleLine("Geriatric Medicine")
 SubjectList.AddSingleLine("Gynaecology")
 SubjectList.AddSingleLine("Haematology")
 SubjectList.AddSingleLine("Hepatology")
 SubjectList.AddSingleLine("Imaging")
 SubjectList.AddSingleLine("Immunology")
 SubjectList.AddSingleLine("Infectious Diseases")
 SubjectList.AddSingleLine("Investigations")
 SubjectList.AddSingleLine("Lists")
 SubjectList.AddSingleLine("Microbiology")
 SubjectList.AddSingleLine("Nephrology")
 SubjectList.AddSingleLine("Neurology")
 SubjectList.AddSingleLine("Obstetrics")
 SubjectList.AddSingleLine("Oncology")
 SubjectList.AddSingleLine("Ophthalmology")
 SubjectList.AddSingleLine("Oral Medicine")
 SubjectList.AddSingleLine("Orthopaedics")
 SubjectList.AddSingleLine("Paediatrics")
 SubjectList.AddSingleLine("Pathology")
 SubjectList.AddSingleLine("Pharmacology")
    SubjectList.AddSingleLine("Procedures")
 SubjectList.AddSingleLine("Psychiatry")
 SubjectList.AddSingleLine("Respiratory")
 SubjectList.AddSingleLine("Rheumatology")
 SubjectList.AddSingleLine("Stroke")
 SubjectList.AddSingleLine("Surgery")
 SubjectList.AddSingleLine("Toxicology")
 SubjectList.AddSingleLine("Trials")
 SubjectList.AddSingleLine("Urology")
   
End Sub
Sub SetLVHeights4TextSize(LV As ListView, TwoLine As Boolean, Text1Size As Float, Text2Size As Float, Padding As Float)
   If TwoLine = True Then
      LV.TwoLinesLayout.Label.Top = 0
      LV.TwoLinesLayout.Label.TextSize = Text1Size
      LV.TwoLinesLayout.Label.Height = (Text1Size + (2 * Padding)) * Density
      LV.TwoLinesLayout.SecondLabel.Top = LV.TwoLinesLayout.Label.Height
      LV.TwoLinesLayout.SecondLabel.TextSize = Text2Size
      LV.TwoLinesLayout.SecondLabel.Height = (Text2Size + (2 * Padding)) * Density
      LV.TwoLinesLayout.ItemHeight = LV.TwoLinesLayout.Label.Height + LV.TwoLinesLayout.SecondLabel.Height
      LV.TwoLinesLayout.Label.Gravity = Gravity.CENTER_VERTICAL
      LV.TwoLinesLayout.SecondLabel.Gravity = Gravity.CENTER_VERTICAL
   Else
      LV.SingleLineLayout.Label.Top = 0
      LV.SingleLineLayout.Label.TextSize = Text1Size
      LV.SingleLineLayout.Label.Height = (Text1Size + (2 * Padding)) * Density
      LV.SingleLineLayout.ItemHeight = LV.SingleLineLayout.Label.Height
      LV.SingleLineLayout.Label.Gravity = Gravity.CENTER_VERTICAL
   End If
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub

Sub SubjectList_ItemClick (Position As Int, Value As Object)
  topic = Value
  StartActivity(SecondScreen)


End Sub
 
Last edited:
Top