如何在ScrollView中放置msCardView

时间:2016-12-12 14:37:22

标签: android basic4android

我试图通过此代码在ScrollView中使用CardView按钮,但它不起作用。我定义了一个子,将MyCardView逐个放入ScrollView。我是Basic4Android的新手,我无法理解问题出在哪里!如果您帮助我了解我如何解决它,我将不胜感激!     :`

Sub Globals
 Dim ScrollView1 As ScrollView
End Sub

Sub Activity_Create(FirstTime As Boolean)

ScrollView1.Initialize("ScrollView1")
ScrollView1.Color=0xFFEEEEEE


Activity.AddView(ScrollView1,0,100%y,100%x,100%y-100dip)

MainItems

End Sub


Sub MainItems

 Dim a1 As MSCardView
 a1.Initialize("a1")
 ScrollView1.Panel.AddView(a1,50%x-100dip,20dip,200dip,80dip)


 Dim aLbl As Label
 aLbl.Initialize("aLbl")
 aLbl.Text="Season1"
 aLbl.TextSize=20
 aLbl.Gravity=Gravity.CENTER
 aLbl.Typeface=Typeface.LoadFromAssets("myandroid.ttf")
 aLbl.TextColor=Colors.RGB(50,50,50)
 a1.Panel.AddView(aLbl,50dip,20dip,100dip,40dip)


Dim a2 As MSCardView
a2.Initialize("a2")
ScrollView1.Panel.AddView(a2,50%x-100dip,20dip,200dip,80dip)


Dim aLb2 As Label
aLb2.Initialize("aLb2")
aLb2.Text="Season2"
aLb2.TextSize=20
aLb2.Gravity=Gravity.CENTER
aLb2.Typeface=Typeface.LoadFromAssets("myandroid.ttf")
aLb2.TextColor=Colors.RGB(50,50,50)
a2.Panel.AddView(aLb2,50dip,20dip,100dip,40dip)


Dim a3 As MSCardView
a3.Initialize("a3")
ScrollView1.Panel.AddView(a3,50%x-100dip,20dip,200dip,80dip)


Dim aLb3 As Label
aLb3.Initialize("aLb3")
aLb3.Text="Season3"
aLb3.TextSize=20
aLb3.Gravity=Gravity.CENTER
aLb3.Typeface=Typeface.LoadFromAssets("myandroid.ttf")
aLb3.TextColor=Colors.RGB(50,50,50)
a3.Panel.AddView(aLb3,50dip,20dip,100dip,40dip)

.
.
.
End Sub

`

1 个答案:

答案 0 :(得分:0)

在#Region项目属性之后添加此代码,看看是否有效

#AditionalRes : E:\Barname\Basic4android\Compatible B4A Collection\SDK\extras\android\support\v7\cardview

(您应该在SDK中找到您自己的Android支持文件)

(如果您的SDK文件夹中没有 Android支持文件,则必须通过在谷歌搜索下载该文件)