Sub GetSystemTextColor As Int
Dim co As Int
Dim typedValue As JavaObject
typedValue.InitializeNewInstance("android.util.TypedValue", Null)
Dim theme As JavaObject = Activity
theme = theme.RunMethod("getTheme", Null)
Dim value As Boolean = theme.RunMethod("resolveAttribute", Array As Object(android.R.attr.textColorPrimary, typedValue, True))
If value Then
Return typedValue.GetField("data")
Else
Return Colors.Black '
End If
End Sub
1. As Erel suggested, why don't you use customlistview instead of listview?
2. The code looks like it was generated by AI. it seems to only retrieve the theme's textColorPrimary, and has nothing to do with the listview.
3. If you would like to get the textColorPrimary, you need to initialize the object android.R.attr instead of passing a literal "android.R.attr.textColorPrimary" as a parameter.
4. You'd better post full error log. I guess it's not "can't run" but "can't compile"
Sub GetSystemTextColor As Int
Dim co As Int
Dim typedValue As JavaObject
typedValue.InitializeNewInstance("android.util.TypedValue", Null)
Dim theme As JavaObject = Activity
theme = theme.RunMethod("getTheme", Null)
Dim value As Boolean = theme.RunMethod("resolveAttribute", Array As Object(android.R.attr.textColorPrimary, typedValue, True))
If value Then
Return typedValue.GetField("data")
Else
Return Colors.Black '
End If
End Sub
I haven't used ListView since 1492, CustomListView is vastly better, but I think that's ONE of the MANY limitations of ListView, that you can't have items with different "styles".
ListView1.AddSingleLine("abc")
'ListView1.a
Dim Label1 As B4XView = ListView1.SingleLineLayout.Label
Log(Label1.TextColor) 'Color of the Text
xui.MsgboxAsync(Label1.Color & "," & Label1.TextSize,"")
more times,textcolor=0(white)
i only want set listview1 bgcolor to yellow or black
hot to get not same color?textcolor=black, than bgcolor=white