I'm trying to get a view only scroll-able text box in my application.
I consulted ChatGPT and had it write a couple of "Subs" for this, I'll include them here.
When the code is dropped into my B4A pages application the "TextView" type is marked in red since
the IDE doesn't know that type. I can't find a library for it, some say it's built in? My suspect is that
it's in the Android SDK and need some sort of link up to the Android SDK some how, please help?
I included the comments ChatGPT gave along with the code it generated for me. It seems to be mixed
up somehow on TextView as I interrogated where and how it got this type to use and it simply states
that is is a built in with the couple of required libraries for all B4A applications, right, well, it needs to
learn a bit more. I did say this should work in V12.20 of B4A. I could not provide how to like the item
to any other deep down Android SDK libraries or Java as such though, so I hit it's limit of knowledge.
" TextView1.ScrollingEnabled = True " appears ScrollingEnabled isn't available either?
I also had it write a version using a "Label" and also has the same missing item in the "Label" version
which I'll include here too for those to critique and maybe correct:
I'm still a NOOB with B4A but well versed in C and firmware, etc... What I find missing is a way
to have knowledge of libraries as stand along documents pdf's on the function calls with in and
arguments and returns. Usually can find an answer in the forums with a good amount of time
though. Did I miss some document or another which would have helped with this TextView
issue and what the "Libraries" selector panel libraries have in them which I might need?
ChatGPT is free to use, but I'm happy to use it to get code laid out and then hammer it to what
I need. But with it using things not in the grat B4X booklets pdf's is a bit tiring, any help?
Thanks in advance!
I consulted ChatGPT and had it write a couple of "Subs" for this, I'll include them here.
When the code is dropped into my B4A pages application the "TextView" type is marked in red since
the IDE doesn't know that type. I can't find a library for it, some say it's built in? My suspect is that
it's in the Android SDK and need some sort of link up to the Android SDK some how, please help?
I included the comments ChatGPT gave along with the code it generated for me. It seems to be mixed
up somehow on TextView as I interrogated where and how it got this type to use and it simply states
that is is a built in with the couple of required libraries for all B4A applications, right, well, it needs to
learn a bit more. I did say this should work in V12.20 of B4A. I could not provide how to like the item
to any other deep down Android SDK libraries or Java as such though, so I hit it's limit of knowledge.
ChatGPT code stubs.:
'=================================================
'In this example, we define a separate CreateTextViewWithScrolling sub that
'takes a text parameter and returns a TextView. This sub creates the ScrollView
'and TextView with the given text, and adds the TextView to the ScrollView's panel.
'The Activity_Create sub then calls this sub to create the TextView and add it to
'activity's view hierarchy. This way, you can create a TextView with scrolling
'and no edit anytime by calling the CreateTextViewWithScrolling sub and passing
'it the desired text as a parameter.
'In this updated code, we declare the variables For the ScrollView And
'TextView at the top of the CreateTextViewWithScrolling sub, and then
'create And Initialize them later in the code. This makes the code more
'readable And easier To modify.
Sub Activity_Create(FirstTime As Boolean)
' Call CreateTextViewWithScrolling sub to create the TextView
Dim TextView1 As TextView = CreateTextViewWithScrolling("This is a long text that requires scrolling to see all of it.")
Activity.AddView(TextView1, 0, 0, 100%x, 100%y)
End Sub
Sub CreateTextViewWithScrolling(text As String) As TextView
' Declare variables
Dim ScrollView1 As ScrollView
Dim TextView1 As TextView
' Create a ScrollView to contain the TextView
ScrollView1.Initialize(0, 0, 100%x, 100%y)
' Create a TextView with scrolling enabled and editing disabled
TextView1.Initialize("TextView1")
TextView1.Text = text
TextView1.Color = Colors.White
TextView1.Gravity = Gravity.LEFT
TextView1.TextSize = 16
TextView1.ScrollingEnabled = True
TextView1.Enabled = False ' Disable editing
' Add the TextView to the ScrollView's panel
ScrollView1.Panel.AddView(TextView1, 0, 0, 100%x, 100%y)
' Return the created TextView
Return TextView1
End Sub
" TextView1.ScrollingEnabled = True " appears ScrollingEnabled isn't available either?
I also had it write a version using a "Label" and also has the same missing item in the "Label" version
which I'll include here too for those to critique and maybe correct:
ChatGPT code stubs, text box, scrollable, no edit. No comple?:
Sub Page_Create(Title As String)
' Create a ScrollView to contain the Label
Dim ScrollView1 As ScrollView
ScrollView1.Initialize("ScrollView1")
Page.RootPanel.AddView(ScrollView1, 0, 0, 100%x, 100%y)
' Call CreateLabelWithScrolling sub to create the Label
Dim lbl As Label
lbl = CreateLabelWithScrolling("This is a long text that requires scrolling to see all of it.")
' Add the Label to the ScrollView's panel
ScrollView1.Panel.AddView(lbl, 0, 0, 100%x, 100%y)
End Sub
Sub CreateLabelWithScrolling(text As String) As Label
' Declare variables
Dim ScrollView1 As ScrollView
Dim Label1 As Label
' Create a ScrollView to contain the Label
ScrollView1.Initialize(0, 0, 100%x, 100%y)
' Create a Label with scrolling enabled and text wrapping
Label1.Initialize("Label1")
Label1.Text = text
Label1.Color = Colors.White
Label1.Gravity = Gravity.LEFT
Label1.TextSize = 16
Label1.SingleLine = False
Label1.ScrollingEnabled = True
' Add the Label to the ScrollView's panel
ScrollView1.Panel.AddView(Label1, 0, 0, 100%x, 100%y)
' Return the created Label
Return Label1
End Sub
I'm still a NOOB with B4A but well versed in C and firmware, etc... What I find missing is a way
to have knowledge of libraries as stand along documents pdf's on the function calls with in and
arguments and returns. Usually can find an answer in the forums with a good amount of time
though. Did I miss some document or another which would have helped with this TextView
issue and what the "Libraries" selector panel libraries have in them which I might need?
ChatGPT is free to use, but I'm happy to use it to get code laid out and then hammer it to what
I need. But with it using things not in the grat B4X booklets pdf's is a bit tiring, any help?
Thanks in advance!