سلام استاد برای ست کردن اندازه لیبل با متن طبق اموزشتون این کدارو میزارم
ولی هیچ متنی نشون نمیده
اکتیویتی
Sub Activity_Create(FirstTime As Boolean)
db.Initialize
lItem=db.ListItems
rec_Layout.Builder("rec").NormalRecycler.BALayout.ListView.RecyclerView _
.withDefaultDividier(rec_Layout.Oriantation_Vertical).Build
Activity.AddView(rec_Layout,0,0,100%x,100%y)
rec_Layout.ShowRecycler
end sub
Private Sub rec_getItemCount As Int
Return lItem.Size
End Sub
Private Sub rec_onBindViewHolder(layoutitem As Object,position As Int,viewtype As Int) As Object
Dim pnl As Panel=layoutitem
pnl.Width=100%x
Dim item As tSMS=lItem.Get(position)
Dim lbl As Label=pnl.GetView(0)
pnl.Color=Colors.Blue
lbl.Gravity=Gravity.CENTER
Dim ht As Int=getLableHeight(item.Scontent,lbl,20)
Dim btnLike As Button=pnl.GetView(1)
btnLike.Top=lbl.Height+lbl.Top+10dip
btnLike.Height=60dip
btnLike.Text="like"
Return ht+btnLike.Height+20dip
End Sub
Private Sub rec_onCreateViewHolder(layoutitem As Object,viewtype As Int) As Object
Dim pnl As Panel=layoutitem
Dim lbl As Label
lbl.Initialize("")
pnl.AddView(lbl,0,0,100%x,0)
Dim btnLike As Button
btnLike.Initialize("")
pnl.AddView(btnLike,50%x-50dip,100dip,100dip,0)
Return Null
End Sub
Sub getLableHeight(txt As String,leb As Label,size As Int) As Float
Dim ht As Int
leb.text=txt
Log(txt)
leb.TextSize=size
leb.TextColor=Colors.White
leb.Gravity=Gravity.CENTER
ht = StrUtil.MeasureMultilineTextHeight(leb , txt)
leb.Height = ht+40dip
Return leb.Height
End Sub
داخل Sub getLableHeight متن رو لاگ میگیرم نشون میده ولی به اداپتور نمیده
اینم کلاس دیتابیس
Public Sub Initialize
' Dim str1() As String = Regex.Split("<#>",File.ReadString(File.DirAssets,"ac.txt"))
Try
If File.Exists(File.DirInternal,"smsdb.db")=False Then
File.Copy(File.DirAssets,"smsdb.db",File.DirInternal,"smsdb.db")
End If
If sql.IsInitialized = False Then
sql.Initialize(File.DirInternal,"smsdb.db",True)
End If
Catch
Log(LastException)
End Try
End Sub
Sub getListItems As List
Dim cur As Cursor
Dim list1 As List
list1.Initialize
cur = sql.ExecQuery("SELECT * from smsdb")
For i=0 To cur.RowCount-1
cur.Position = i
Dim t1 As tSMS
t1.Initialize
t1.Sid = cur.GetInt("id")
t1.Scontent = cur.GetString("sms")
list1.Add(t1)
Next
Return list1
End Sub