Android Question CustomListView

chevita87

Member
Licensed User
I have a problem, when I want to pass the information to the customlistview, load the layout but don't show the information, I upload my app, so you help me
 

Attachments

  • CMV.zip
    217.3 KB · Views: 135

Mahares

Expert
Licensed User
Longtime User
so you help me
You are using a target SDK of 26 in manifest and File.DirrootExternal to store data. You need to use runtime permissions for it to work:
You need this in starter service. Do not forget to add the runtimePermissions library:
B4X:
Sub Process_Globals
    Public rp As RuntimePermissions  'need runtimePermissions library
End Sub
You also need this in Activity_Create:
B4X:
Sub Activity_Create(FirstTime As Boolean)
    Starter.rp.CheckAndRequest(Starter.rp.PERMISSION_WRITE_EXTERNAL_STORAGE)  '
    Wait For Activity_PermissionResult (Permission As String, PResult As Boolean)
    If PResult = False Then
        MsgboxAsync("No permission to access external storage", "")
        Return
    Else
        Log("Granted")
    End If
    Activity.LoadLayout("Main")
    Activity.AddMenuItem("Principal", "main")
    Activity.AddMenuItem("Datos", "datos")
    Activity.AddMenuItem("Brucelosis", "brucelosis")
    Activity.AddMenuItem("Tuberculosis", "tuberculosis")
    Activity.AddMenuItem("Salir", "salir")
  
    lstTextB.Initialize
    lstTextT.Initialize
  
End Sub
There may be other stuff, but I do not understand the Spanish text on your buttons and menus.
 
Upvote 0

chevita87

Member
Licensed User
You are using a target SDK of 26 in manifest and File.DirrootExternal to store data. You need to use runtime permissions for it to work:
You need this in starter service. Do not forget to add the runtimePermissions library:
B4X:
Sub Process_Globals
    Public rp As RuntimePermissions  'need runtimePermissions library
End Sub
You also need this in Activity_Create:
B4X:
Sub Activity_Create(FirstTime As Boolean)
    Starter.rp.CheckAndRequest(Starter.rp.PERMISSION_WRITE_EXTERNAL_STORAGE)  '
    Wait For Activity_PermissionResult (Permission As String, PResult As Boolean)
    If PResult = False Then
        MsgboxAsync("No permission to access external storage", "")
        Return
    Else
        Log("Granted")
    End If
    Activity.LoadLayout("Main")
    Activity.AddMenuItem("Principal", "main")
    Activity.AddMenuItem("Datos", "datos")
    Activity.AddMenuItem("Brucelosis", "brucelosis")
    Activity.AddMenuItem("Tuberculosis", "tuberculosis")
    Activity.AddMenuItem("Salir", "salir")
 
    lstTextB.Initialize
    lstTextT.Initialize
 
End Sub
There may be other stuff, but I do not understand the Spanish text on your buttons and menus.

thanks for the answer, but where is the information that you give me with my customlistview problem related?
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Please help us help you. Give more information about the problem. Where is the code that should add the items? How are you calling it?

What are the steps to reproduce it?

Note that the manifest editor code is wrong. Also the anchors are not used correctly. The issue is described in the visual designer video tutorial: https://www.b4x.com/etp.html
 
Upvote 0

chevita87

Member
Licensed User
Please help us help you. Give more information about the problem. Where is the code that should add the items? How are you calling it?

What are the steps to reproduce it?

Note that the manifest editor code is wrong. Also the anchors are not used correctly. The issue is described in the visual designer video tutorial: https://www.b4x.com/etp.html

B4X:
Sub CreateListItemB(Text As String, Width As Int, Height As Int) As Panel
    Dim p As Panel
    p.Initialize("")
    p.SetLayout(0, 0, Width, Height)
    p.LoadLayout("ListB")
    Text = ((lbTuboB.Text=txtTuboB.Text)&(lbAnimalB.Text=txtAnimalNB.Text)&(lbCategoriaB.Text=txtCategoriaB.SelectedItem))
    Return p
End Sub

this is the code that create the item
B4X:
Sub btnAgregarB_Click
   
    lstTextB.InsertAt(0, txtTuboB.Text&" , "&txtAnimalNB.Text&" , "&txtCategoriaB.SelectedItem)
       
    lstCaravanasB.Clear
   
    For i = 0 To lstTextB.Size - 1
        lstCaravanasB.Add(CreateListItemB(i,lstCaravanasB.AsView.Width,40dip),i)
    Next
   
    txtTuboB.Text=""
    txtAnimalNB.Text=""

End Sub

And this is the button to add the item

When i added the item i get it in blank

And what is wrong with the manifest?
 
Upvote 0
Top