Typeface SERIF for ListView

ukimiku

Active Member
Licensed User
Longtime User
I try to set the typeface for a listview to the default SERIF font, style normal:
B4X:
Dim tface As Typeface
tface = Typeface.CreateNew(Typeface.SERIF, Typeface.STYLE_NORMAL)
Dim formload_listview As ListView
formload_listview.Initialize("formload_listview")
formload_listview.SingleLineLayout.Label.Typeface = tface
formload_listview.Invalidate

The invalidate, I read, can be used to force the listview to redraw itself. Anyhow, it stubbornly keeps its SANS_SERIF typeface.

How to go about it?

Thanks! Regards,
 

mc73

Well-Known Member
Licensed User
Longtime User
Are you trying to create a new Listview or have you already set your listview in design mode? If you've done the latter, I think you should remove 'Dim formload_listview' and 'formload_listview.initialize'.
 
Upvote 0

ukimiku

Active Member
Licensed User
Longtime User
mc73,

thank you for replying. The listview was in fact created with the designer.

If I comment-out both lines of code, the project won't compile anymore:

Compiling code. Error
Error parsing program.
Error description: Undeclared variable 'formload_listview' is used before it was assigned any value.

If I comment-out only the initializing line, the program starts but then throws an exception that says that the listview had not been initialized properly.

Strangely, I cannot put these lines into Activity_Create; then the compiler complains about code in a button click event handler that refers to the listview (makes it visible), so I have to have the lines in the "Globals" section of the program. Do you know why this is so?

Thank you.

Regards,


Edit: the problem is now solved. You got me thinking about the designer, and now I am adding the listview via code. Success. Thanks!
 
Last edited:
Upvote 0

mc73

Well-Known Member
Licensed User
Longtime User
you should dim your listview in sub globals :)

From designer, choose 'tools'->'generate members'. Then select 'dim' for your listview, and the click event.
 
Upvote 0
Top