Android Question Blank text retrieval from sqlite db

WofaCle

Member
The Attached image is the result i get whenever i run the app please help me fix it
I am retrieving the text from sqlite db browser but the text thats no appear on Labelforlg


B4X:
Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.
    
    
    Dim strUtils As StringUtils
    Private LG_ScrollView As ScrollView
    Private Labelhead1 As Label
    Private LabelforLg As Label
End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    Activity.LoadLayout("LGPageDetails")
    LG_ScrollView.Panel.LoadLayout("lgdetaillbl")
    
    Dim rs As ResultSet
    rs = Starter.SQL1.ExecQuery("SELECT * FROM LGDetails WHERE PageTitle = '" & Starter.PageTitle & "' ")
    Do While rs.NextRow
        
        LabelforLg.Text = rs.GetString("Body")
        Labelhead1.Text = rs.GetString("PageTitle")
        LG_ScrollView.Panel.Height = LabelforLg.Height
        LabelforLg.Height = strUtils.MeasureMultilineTextHeight(LabelforLg, LabelforLg.Text)
                
    Loop
    rs.Close
End Sub
 

Attachments

  • Capture1.PNG
    Capture1.PNG
    14.3 KB · Views: 102

zed

Active Member
Licensed User
You set the height of the scrollpane to the height of the label. Then you modify the height of the label.
Maybe the height is no longer correct.
With a small project, we could test and find out what's wrong
 
Upvote 0

Brian Dean

Well-Known Member
Licensed User
Longtime User
Have you logged rs.GetString("Body") to check what is actually being returned from the query? In any case you should look at item 5 in Erel's "Code Smells". But I think that @zed is probably right - you seem to be using LabelforLg.Height before you have set the value.
 
Upvote 0

WofaCle

Member
Have you logged rs.GetString("Body") to check what is actually being returned from the query? In any case you should look at item 5 in Erel's "Code Smells". But I think that @zed is probably right - you seem to be using LabelforLg.Height before you have set the value.
Yes i tried logged the rs.GetString("Body") and it worked. Also i retrieved the query again by selecting only the table it also worked but after adding Starter.PageTitle to it thats where comes blank on the label please @zed please help me with the height of the scrollpane and tge label am using current version 12.8
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
According to the answer in post #2, have you tried this, ?

B4X:
    Do While rs.NextRow
        
        LabelforLg.Text = rs.GetString("Body")
        Labelhead1.Text = rs.GetString("PageTitle")
        LabelforLg.Height = strUtils.MeasureMultilineTextHeight(LabelforLg, LabelforLg.Text)
        LG_ScrollView.Panel.Height = LabelforLg.Height
    Loop

Inverting the two last lines in the loop.
 
Upvote 0
Top