Android Question AS Settings SelectionList

Sergio Haurat

Active Member
Licensed User
Longtime User
Hi @Alexander Stolte, I am trying to implement "SelectionList". I downloaded the example file in #1 and couldn't find a code segment that explains the correct way to do it.

The example code seen above:
- What would be the way to call .ShowPage?
- Is there a way to change the text size of the elements to make them smaller? (I have some records with text that does not look good, so large and with so many characters)

I have managed to run using .ShowPage in .Action, but when selecting an item, it returns the following error.

** Activity (main) Resume **
Error occurred on line: 1604 (AS_SettingsPage)
java.lang.RuntimeException: Object should first be initialized (View).
Did you forget to call Activity.LoadLayout?
at anywheresoftware.b4a.AbsObjectWrapper.getObject(AbsObjectWrapper.java:67)
at anywheresoftware.b4a.objects.B4XViewWrapper.GetView(B4XViewWrapper.java:335)
at ar.com.sysprofile.psahb.as_settingspage._refreshselectionlistitems(as_settingspage.java:3397)
at ar.com.sysprofile.psahb.as_settingspage._selectionitem_click(as_settingspage.java:3507)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:348)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:157)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:201)
at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:80)
at android.view.View.performClick(View.java:7535)
at android.view.View.performClickInternal(View.java:7512)
at android.view.View.-$$Nest$mperformClickInternal(Unknown Source:0)
at android.view.View$PerformClick.run(View.java:29488)
at android.os.Handler.handleCallback(Handler.java:984)
at android.os.Handler.dispatchMessage(Handler.java:104)
at android.os.Looper.loopOnce(Looper.java:238)
at android.os.Looper.loop(Looper.java:357)
at android.app.ActivityThread.main(ActivityThread.java:8118)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:957)

B4X:
Sub Class_Globals
    Private pnlSettings As AS_Settings
    Private pnlSettingPage As AS_SettingsPage
End Sub
B4X:
        'AS_Settings
        pnlSettings.MainPage.AddGroup("set_basic", mdlFunctions.loc.Localize("def_values"))
        pnlSettings.MainPage.AddDescriptionItem("set_basic", mdlFunctions.loc.Localize("set_fed_club"))
        pnlSettings.MainPage.AddProperty_Action("set_basic", "fed_action", mdlFunctions.loc.Localize("fed"), "", Null, mdlFunctions.loc.Localize("cmb_select"))
        pnlSettings.MainPage.AddGroup("set_advance", mdlFunctions.loc.Localize("set_advance"))
        pnlSettings.MainPage.AddProperty_Boolean("set_advance", "appConnect", mdlFunctions.loc.Localize("set_user_login"), mdlFunctions.loc.Localize("link_app"), Null, False)
        pnlSettingPage.Initialize(pnlSettings, mdlFunctions.loc.Localize("opt_short"))
        pnlSettingPage.AddGroup("selection", mdlFunctions.loc.Localize("fed"))
        Dim lstItems As List
        lstItems.Initialize
        For Each intID As Int In mdlFunctions.map_cmn_lst_federaciones.Keys
            Dim strItem As String = mdlFunctions.map_cmn_lst_federaciones.Get(intID).As (List).Get(0).As (String)
            lstItems.Add(pnlSettings.CreateSelectionListItem(strItem, Null, intID))
        Next
        pnlSettingPage.AddProperty_SelectionList("selection", "federation", lstItems, Array(), False, True)
        pnlSettings.MainPage.Create
        'AS_Settings
B4X:
Private Sub pnlSettings_ActionClicked(Property As AS_Settings_Property)
    Select Case Property.PropertyName
        Case "fed_action"
            pnlSettingPage.ShowPage()
    End Select
End Sub

Graphic example to show you the problem with text size

1709819057085.png
 

Alexander Stolte

Expert
Licensed User
Longtime User
What would be the way to call .ShowPage?
In the main example project of the AS_Settings, there is an example with a 2nd page, search for SettingPage2 in the ide to find it.

Is there a way to change the text size of the elements to make them smaller? (I have some records with text that does not look good, so large and with so many characters)
No there is not yet, the text size is still hardcoded for the SelectionList

have managed to run using .ShowPage in .Action, but when selecting an item, it returns the following error.
Please provide an example project, what shows the error. I can't help you with just an error message.
 
Upvote 0

Sergio Haurat

Active Member
Licensed User
Longtime User
Another wish that I have is to be able to pass to the ComboBox a Map variable instead of List, by this way, I can obtain a code for each record, when I capture the value of the ID as happens with "_ValueChanged(Property As AS_Settings_Property, Value As Object)".

Otherwise, I have to send only the descriptive text of the record and when the selection event is executed, go through the Map variable by its description to know the code.

VB.Net example
B4X:
Dim strSQL As String
Dim adm_lst_docs As New DataTable
strSQL = "select"
strSQL &= " adm_lst_docs._id as adm_lst_docs_id,"
strSQL &= " adm_lst_docs._desc" & strMyLang & " as adm_lst_docs_desc"
strSQL &= " from adm_lst_docs"
strSQL &= " order by"
strSQL &= " adm_lst_docs_desc"
MySQLCmdInterSys.CommandText = strSQL
MySQLDAInterSys.SelectCommand = MySQLCmdInterSys
MySQLDAInterSys.Fill(adm_lst_docs)
Me.cmbTypeDoc.DataSource = adm_lst_docs
Me.cmbTypeDoc.DisplayMember = "adm_lst_docs_desc"
Me.cmbTypeDoc.ValueMember = "adm_lst_docs_id"
 
Upvote 0

Alexander Stolte

Expert
Licensed User
Longtime User
I'm still having problems with the code
And how am I supposed to know what these problems are? I have tried the example and when I select something there is no more error.

I'm sorry, but I don't feel like programming right now, I'll be expanding the library over the next few days/weeks.
 
Last edited:
Upvote 0

Sergio Haurat

Active Member
Licensed User
Longtime User
And how am I supposed to know what these problems are? I have tried the example and when I select something there is no more error.

I'm sorry, but I don't feel like programming right now, I'll be expanding the library over the next few days/weeks.
The problem remains the same. In the original post I attached an example that generates the error. I understand that you can test it from there.

Sorry if this is annoying, but in the library example there is no example of "AddProperty_SelectionList", only a link to part of the code without any explanation of how to integrate it into the rest of the project.
 
Upvote 0

Alexander Stolte

Expert
Licensed User
Longtime User
The problem remains the same. In the original post I attached an example that generates the error.
Again. I have downloaded the last b4xlib on the lib. thread, open your example project from #3 and there is no error if i select something on the list in B4A.

Sorry if this is annoying, but in the library example there is no example of "AddProperty_SelectionList", only a link to part of the code without any explanation of how to integrate it into the rest of the project.
You're right about that.
 
Upvote 0

Alexander Stolte

Expert
Licensed User
Longtime User
Sorry if this is annoying, but in the library example there is no example of "AddProperty_SelectionList", only a link to part of the code without any explanation of how to integrate it into the rest of the project.
New Example Project:
 
Upvote 0

Sergio Haurat

Active Member
Licensed User
Longtime User
Upvote 0

Sergio Haurat

Active Member
Licensed User
Longtime User
I think this is a bug, if you select the same element (an already selected element), the value is null instead of the value assigned to that element.

1710097414936.png
 
Upvote 0
Top