tc.IndentationLevel = 1
tc.IndentationWidth = (tablevpnl.Width/2) - (tc.Text.ToString.MeasureWidth(Font.CreateNew(16*density))/2)
Sub CreateCenteredAttrString(Text As String, aFont As Font, Color As Int) As AttributedString
Dim NaObj1 As NativeObject
NaObj1 = NaObj1.Initialize("NSMutableParagraphStyle").RunMethod("new",Null)
NaObj1.SetField("alignment",1)
Dim Attr As Map = CreateMap("NSColor":NaObj1.ColorToUIColor(Color),"NSParagraphStyle":NaObj1,"NSFont":aFont)
Dim NaObj2 As NativeObject
NaObj2 = NaObj2.Initialize("NSAttributedString").RunMethod("alloc",Null).RunMethod("initWithString:attributes:",Array(Text,Attr.ToDictionary))
Return NaObj2
End Sub
Hi,
use this sub to create the AttributedString
B4X:Sub CreateCenteredAttrString(Text As String, aFont As Font, Color As Int) As AttributedString Dim NaObj1 As NativeObject NaObj1 = NaObj1.Initialize("NSMutableParagraphStyle").RunMethod("new",Null) NaObj1.SetField("alignment",1) Dim Attr As Map = CreateMap("NSColor":NaObj1.ColorToUIColor(Color),"NSParagraphStyle":NaObj1,"NSFont":aFont) Dim NaObj2 As NativeObject NaObj2 = NaObj2.Initialize("NSAttributedString").RunMethod("alloc",Null).RunMethod("initWithString:attributes:",Array(Text,Attr.ToDictionary)) Return NaObj2 End Sub
Jan
For i = 0 To Main.sal_timelist.Size - 1
Dim timeproc As saltotalcalc = Main.sal_timelist.Get(i)
Dim str As AttributedString
str.Initialize(timeproc.procent & "%" & " --> " & Floor(timeproc.minutes/60) & ":" & NumberFormat2(timeproc.minutes Mod 60,2,0,0,False), Font.CreateNew(16*density),Colors.RGB(43,43,43))
Dim tc As TableCell = timeTableview.AddSingleLine("")
tc.Text = str
tc.AccessoryType = tc.ACCESSORY_DETAIL_BUTTON
tc.IndentationLevel = 1
tc.IndentationWidth = (tablevpnl.Width/2.5) - (tc.Text.ToString.MeasureWidth( Font.CreateNew(16*density))/2)
Next
Yes.is it possible with the sub you posted?
For i = 0 To Main.sal_timelist.Size - 1
Dim timeproc As saltotalcalc = Main.sal_timelist.Get(i)
Dim tc As TableCell = timeTableview.AddSingleLine("")
tc.Text = CreateCenteredAttrString(timeproc.procent & "%" & " --> " & Floor(timeproc.minutes/60) & ":" & NumberFormat2(timeproc.minutes Mod 60,2,0,0,False), Font.CreateNew(16*density),Colors.RGB(43,43,43))
tc.AccessoryType = tc.ACCESSORY_DETAIL_BUTTON
Next
If you are not 100% happy you could also try to create a custom cell with the CustomView property of TableCell.
Jan