Android Question How can i get Label text from a CustomListView

Olá,
Não consigo obter o texto de uma etiqueta criada no designer e que se encontra numa CustomListView.
A CustomListView tem várias visualizações, que são rótulos e uma imageView. O que procuro fazer é obter o texto de uma das etiquetas quando fizer clique no item de CustomListView.
Está a retornar um erro que diz que uma visualização deve ser inicializada.
Ora, se não me engano, as visualizações elevadas no designer estão inicializadas.
Coloco de seguida, o método e o erro:

O método B4X:
Private Sub clvEligiblesContent_ItemClick (Index As Int, value As Object)
    
    ' Vai preencher um mapa com os items que forem selecionados
    ' No caso de haver um sdcard os nomes dos items vão aparecer 
    ' repetidos, então o mapa vai ter como key o path do item e
    ' como value o seu nome. Ao guardar os valores, na tabela, para
    ' coluna do nome, vai o valor do mapa e para a coluna do path,
    ' vai a chave do mapa
    
    'Dim PathValue As Label
    Dim text As String = clvEligiblesContent.GetPanel(Index).GetView(3).Text
    Log(text)
    'Dim  item As CLVItem = clvEligiblesContent.GetRawListItem(Index)
    
'    Dim folderPath As String
'    If Not (Starter.EligiblesSelected.IsInitialized) Then
'        Starter.EligiblesSelected.Initialize
'    End If
'   
'    For Order = 0 To Starter.AllEligeblesFolders.Size -1 Step 1
'        folderPath = Starter.AllEligeblesFolders.GetKeyAt(Order)
'        If Not (folderPath.EndsWith(value))   Then
'            Continue
'        else If folderPath.EndsWith(value)Then
'            Dim folder As String = Starter.AllEligeblesFolders.Get(folderPath)
'            Log (folder.ToUpperCase & CRLF & folderPath)
'            Starter.EligiblesSelected.Put(folderPath,folder)
'        End If
'    Next
    
    
    'Log(Index & ":" & value)
'    itemFolder = value
'    Activity.RemoveAllViews
'    SettingsAtFirstRun.lblPage.Text = value
'    pagemanager.ShowPage("PageSettingsAtFirstRun")
'Activity.Finish
'StartActivity(Me)
End Sub

E agora os logs:
Erro:
** Receiver (clock) OnReceive **
** Service (clock) Start **
** Receiver (devicecontentobserver) OnReceive **
** Service (devicecontentobserver) Start **
** Receiver (devicecontentobserver) OnReceive **
** Service (devicecontentobserver) Start **
** Receiver (clock) OnReceive **
** Service (clock) Start **
** Receiver (devicecontentobserver) OnReceive **
** Service (devicecontentobserver) Start **
** Receiver (clock) OnReceive **
** Service (clock) Start **
** Receiver (clock) OnReceive **
** Service (clock) Start **
** Receiver (devicecontentobserver) OnReceive **
** Service (devicecontentobserver) Start **
** Receiver (clock) OnReceive **
** Service (clock) Start **
** Receiver (devicecontentobserver) OnReceive **
** Service (devicecontentobserver) Start **
** Receiver (devicecontentobserver) OnReceive **
** Service (devicecontentobserver) Start **
** Receiver (clock) OnReceive **
** Service (clock) Start **
** Receiver (devicecontentobserver) OnReceive **
** Service (devicecontentobserver) Start **
** Receiver (clock) OnReceive **
** Service (clock) Start **
** Receiver (devicecontentobserver) OnReceive **
** Service (devicecontentobserver) Start **
** Receiver (clock) OnReceive **
** Service (clock) Start **
** Receiver (devicecontentobserver) OnReceive **
** Service (devicecontentobserver) Start **
** Receiver (clock) OnReceive **
** Service (clock) Start **
** Receiver (devicecontentobserver) OnReceive **
** Service (devicecontentobserver) Start **
** Receiver (clock) OnReceive **
** Service (clock) Start **
** Receiver (clock) OnReceive **
** Service (clock) Start **
** Receiver (devicecontentobserver) OnReceive **
** Service (devicecontentobserver) Start **
** Receiver (clock) OnReceive **
** Service (clock) Start **
** Receiver (devicecontentobserver) OnReceive **
** Service (devicecontentobserver) Start **
** Receiver (clock) OnReceive **
** Service (clock) Start **
** Receiver (devicecontentobserver) OnReceive **
** Service (devicecontentobserver) Start **
** Receiver (clock) OnReceive **
** Service (clock) Start **
** Receiver (devicecontentobserver) OnReceive **
** Service (devicecontentobserver) Start **
** Receiver (clock) OnReceive **
** Service (clock) Start **
** Receiver (devicecontentobserver) OnReceive **
** Service (devicecontentobserver) Start **
** Receiver (clock) OnReceive **
** Service (clock) Start **
** Receiver (devicecontentobserver) OnReceive **
** Service (devicecontentobserver) Start **
** Receiver (clock) OnReceive **
** Service (clock) Start **
** Receiver (devicecontentobserver) OnReceive **
** Service (devicecontentobserver) Start **
** Receiver (devicecontentobserver) OnReceive **
** Service (devicecontentobserver) Start **
** Receiver (clock) OnReceive **
** Service (clock) Start **
** Receiver (devicecontentobserver) OnReceive **
** Service (devicecontentobserver) Start **
** Receiver (clock) OnReceive **
** Service (clock) Start **
** Receiver (devicecontentobserver) OnReceive **
** Service (devicecontentobserver) Start **
** Receiver (clock) OnReceive **
*** Service (starter) Create ***
** Service (starter) Start **
Serviço starter IP: 192.168.1.74
Serviço starter Wifi-IP: 192.168.1.74
** Service (clock) Create **
** Service (clock) Start **
Service started in foreground mode.
** Service (clock) Start **
*** Service (devicecontentobserver) Create ***
Partial wakeLock already held.
** Service (devicecontentobserver) Start **
*** Service (firebasemessaging) Create ***
** Service (firebasemessaging) Start **
*** Service (starter) Create ***
** Service (starter) Start **
Serviço starter IP: 192.168.1.74
Serviço starter Wifi-IP: 192.168.1.74
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
*** Service (clock) Create ***
** Service (clock) Start **
*** Service (devicecontentobserver) Create ***
Partial wakeLock already held.
** Service (devicecontentobserver) Start **
*** Service (firebasemessaging) Create ***
** Service (firebasemessaging) Start **
Encontrado:  Repository.db
****** DIRECTORIOS ELEGIVEIS *********
****** DIRECTORIOS ELEGIVEIS *********
Encontrado:  Repository.db
BASE DE DADOS ACTIVA ? true
ExecuteMemoryTable: PRAGMA table_info ('Eligibles')
ExecuteMemoryTable: SELECT name FROM sqlite_master WHERE type = 'table'
TABELAS:
Eligibles
*** Service (repositoryprovider) Create ***
** Service (repositoryprovider) Start **
** Receiver (clock) OnReceive **
** Activity (main) Pause, UserClosed = true **
** Service (clock) Start **
** Receiver (devicecontentobserver) OnReceive **
** Service (devicecontentobserver) Start **
** Activity (settings) Create, isFirst = true **
Call B4XPages.GetManager.LogEvents = True to enable logging B4XPages events.
Adequar Layout para ->
** Activity (settings) Resume **
** Receiver (clock) OnReceive **
** Activity (settings) Pause event (activity is not paused). **
** Service (clock) Start **
** Receiver (devicecontentobserver) OnReceive **
** Service (devicecontentobserver) Start **
** Activity (eligibles) Create, isFirst = true **
Call B4XPages.GetManager.LogEvents = True to enable logging B4XPages events.
** Activity (eligibles) Resume **
** Receiver (clock) OnReceive **
** Service (clock) Start **
** Receiver (clock) OnReceive **
** Service (clock) Start **
** Receiver (devicecontentobserver) OnReceive **
** Service (devicecontentobserver) Start **
eligibles_clveligiblescontent_itemclick (java line: 502)
java.lang.RuntimeException: Object should first be initialized (View).
    at anywheresoftware.b4a.AbsObjectWrapper.getObject(AbsObjectWrapper.java:67)
    at anywheresoftware.b4a.objects.B4XViewWrapper.GetView(B4XViewWrapper.java:318)
    at com.nunoduraes.audioplayerorganizer.eligibles._clveligiblescontent_itemclick(eligibles.java:502)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:213)
    at anywheresoftware.b4a.keywords.Common.CallSub4(Common.java:1082)
    at anywheresoftware.b4a.keywords.Common.CallSubNew3(Common.java:1045)
    at b4a.example3.customlistview$ResumableSub_PanelClickHandler.resume(customlistview.java:805)
    at b4a.example3.customlistview._panelclickhandler(customlistview.java:748)
    at b4a.example3.customlistview._panel_click(customlistview.java:735)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:213)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:193)
    at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:80)
    at android.view.View.performClick(View.java:7870)
    at android.view.View.performClickInternal(View.java:7839)
    at android.view.View.access$3600(View.java:886)
    at android.view.View$PerformClick.run(View.java:29363)
    at android.os.Handler.handleCallback(Handler.java:883)
    at android.os.Handler.dispatchMessage(Handler.java:100)
    at android.os.Looper.loop(Looper.java:237)
    at android.app.ActivityThread.main(ActivityThread.java:7948)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1075)
*** Service (starter) Create ***
** Service (starter) Start **
Serviço starter IP: 192.168.1.74
Serviço starter Wifi-IP: 192.168.1.74
** Activity (settings) Create, isFirst = true **
Call B4XPages.GetManager.LogEvents = True to enable logging B4XPages events.
** Activity (settings) Resume **
*** Service (clock) Create ***
** Service (clock) Start **
*** Service (devicecontentobserver) Create ***
Partial wakeLock already held.
** Service (devicecontentobserver) Start **
*** Serviço (firebasemessaging) Criar ***
** Início do serviço (firebasemessaging) **
** Receptor (relógio) OnReceive **
** Início do serviço (relógio) **
** Receiver (devicecontentobserver) OnReceive **
** Início do serviço (devicecontentobserver) **
** Receptor (relógio) OnReceive **
** Início do serviço (relógio) **
** Receiver (devicecontentobserver) OnReceive **
** Início do serviço (devicecontentobserver) **
** Receptor (relógio) OnReceive **
** Início do serviço (relógio) **
** Receptor (relógio) OnReceive **
** Início do serviço (relógio) **
** Receiver (devicecontentobserver) OnReceive **
** Início do serviço (devicecontentobserver) **
** Receiver (devicecontentobserver) OnReceive **
** Início do serviço (devicecontentobserver) **
** Receptor (relógio) OnReceive **
** Início do serviço (relógio) **
** Receptor (relógio) OnReceive **
** Início do serviço (relógio) **
** Receiver (devicecontentobserver) OnReceive **
** Início do serviço (devicecontentobserver) **
[/CÓDIGO]
 
Thank you Erel, for your prompt response. The problem was solved, but in the designer, no layout view couldn't be exported as B4XView. If so, an error was returned, saying that you should initialize the B4XView. The layout has 3 labels and 1 panel and everything goes as expected if exported views with these types. I don't understand why.
I made a compilation to exemplify this, and leave the activity code, the logs with the error and attach the layout. Also i attached a print screen with a warning abaut panel created in designer.
( I'm sorry, but it seams I wasn't able to use the code tag in this editor, so I attached the files)
 

Attachments

  • eligibleitemlayout.bal
    3.5 KB · Views: 33
  • Eligibles.txt
    6.3 KB · Views: 36
  • Object should first be initialized (B4XView).txt
    2.1 KB · Views: 38
  • painelWarning.png
    painelWarning.png
    362.8 KB · Views: 55
Last edited:
Upvote 0
Top