Android Question views added to customview at runtime

elitevenkat

Active Member
Licensed User
Longtime User
hi
when i add a button to a customview, the button appears but not he text.
same way when i create a spinner in run time and add to customview, the spinner appears with data but the drop down icon is not appearing in the spinner
any additional properties to be set at run time ?
venkat
 

elitevenkat

Active Member
Licensed User
Longtime User
The custom view is scrollview.

code

Dim sv1 As ScrollView
sv1.Top=1%y
sv1.Height=90%y
sv1.Left=1%x
sv1.Width =98%x
'PanelCanvas.Initialize("")

sv1.Panel.AddView(PanelTables,1%x,1%y,96%x,100%y)
sv1.SendToBack
sv1.Panel.Height=PanelTables.Height

Dim lbl As Label
Dim lp As Panel
Dim spn As Spinner

lbl.Initialize("")
lp.Initialize("lp")


spn.Initialize("spn")
spn.Color=Colors.Black
spn.TextColor=Colors.White

lp.AddView(lbl,1%x,1%y,99%x,50dip)



DBUtils.ExecuteSpinner(SQL,"Select fbchoice from AMASTER" , Null,0,spn)

lp.AddView(spn,1%x,lbl.top+32dip,70%x,80dip)

sv1.Panel.AddView(PanelTables,1%x,1%y,96%x,100%y)


dim tnFreeHand as button
btnFreeHand.Initialize("click")
btnFreeHand.Text ="Free Hand Style"


/code

now all the views are appearing with the mentioned short comings mentioned in my previous post.
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
USE CODE TAGS. Dont tell us you dont know
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
ScrollView is not a CustomView but a standard view.
Where is PanelTables declared ?
You have a Panel lp which is never added onto a parent view !?
You add PanelTables twice onto sv1.Panel !?
You dim tnFreeHand as button
Then you use btnFreeHand, not the same name !?
btnFreeHand is never added onto a parent view !?
I'm afraid that this will not work correctly with the height of 100%y in a ScrollView.Panel.
sv1.Panel.AddView(PanelTables,1%x,1%y,96%x,100%y)
100%y is the height of the parent view, in this case sv1.Panel.
It would be easier for us to help if you posted a small project showing the problem.

Code tags must be between square brackets to show the code correctly.
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
Attached a modified version.
You need to calculate the height of PanelTables and sv1.Panel according to the last view you added in the ScrollView.
In your case:
B4X:
PanelTables.Height = etc.Top + etc.Height + 2dip
sv1.Panel.Height = PanelTables.Height
 

Attachments

  • test1.zip
    12 KB · Views: 139
Upvote 0

elitevenkat

Active Member
Licensed User
Longtime User
Thanks for the response. The look and feel of spinner view seems to be different if created in ide and at run time. i am attaching the screen shot images. what is to e done to get the same look and feel of the spinner (ide) from the one created at run time.
Similarly the button view created at run time does not show the text.
 

Attachments

  • spinner-ide.png
    spinner-ide.png
    128.6 KB · Views: 190
  • spinner-runtime.png
    spinner-runtime.png
    93.6 KB · Views: 177
  • buttonruntime.png
    buttonruntime.png
    98.8 KB · Views: 164
Upvote 0

klaus

Expert
Licensed User
Longtime User
Spinner look different depending on the Android version.
The Spinner in picture spinner-ide.jpg is the 'old' look.
If you set in the Manifest Editor android:targetSdkVersion="4" instead of android:targetSdkVersion="14", you'll see the difference.

The text in btnFH is not displayed because the button width is too high, the most part of it is out of the screen !!!
Replace this line
PanelTables.AddView(btnFH,61%x,lp.Top + 120dip,99%x,50dip)
by this one and the text appears !
PanelTables.AddView(btnFH,61%x,lp.Top + 120dip,30%x,50dip)
 
Upvote 0
Top