Sandman Expert Licensed User Longtime User May 15, 2017 #1 Summary: ListView in API Level 24 is not rendered correctly Listview as seen in Level 23 (correctly): ListView as seen in Level 24 (not readable): Reproduction Steps: 1. Add a listview to a layout 2. Add a line to the listview 3. Set manifest to use targetSdkVersion=24 Actual Behavior: The added line is not visible. (I'm guessing it's the same color as the background.) Expected Behavior: The line is visible. Notes (optional): I'm not entirely sure this is a bug, but I can't imagine what I'm doing wrong otherwise. Additional information (optional): Project attached. You need to manually edit the manifest between 23 and 24 for targetSdkVersion to see the issue. Attachments listview_bug.zip listview_bug.zip 8.5 KB · Views: 270
Summary: ListView in API Level 24 is not rendered correctly Listview as seen in Level 23 (correctly): ListView as seen in Level 24 (not readable): Reproduction Steps: 1. Add a listview to a layout 2. Add a line to the listview 3. Set manifest to use targetSdkVersion=24 Actual Behavior: The added line is not visible. (I'm guessing it's the same color as the background.) Expected Behavior: The line is visible. Notes (optional): I'm not entirely sure this is a bug, but I can't imagine what I'm doing wrong otherwise. Additional information (optional): Project attached. You need to manually edit the manifest between 23 and 24 for targetSdkVersion to see the issue.
Erel B4X founder Staff member Licensed User Longtime User May 16, 2017 #2 You need to change the text color: Code: lv.SingleLineLayout.Label.TextColor = Colors.Black Upvote 0
R ronell Well-Known Member Licensed User Longtime User May 16, 2017 #3 you can try Code: if p.sdkversion <= 23 then 'do nothing else 'do the code here to make the background color black end if Upvote 0
you can try Code: if p.sdkversion <= 23 then 'do nothing else 'do the code here to make the background color black end if
Erel B4X founder Staff member Licensed User Longtime User May 16, 2017 #4 I don't think that this is the correct approach. It is better to explicitly decide whether you want a light or dark theme (code to set light theme is available here: https://www.b4x.com/android/forum/threads/b4a-v5-80-beta-is-released.63300/#content). Upvote 0
I don't think that this is the correct approach. It is better to explicitly decide whether you want a light or dark theme (code to set light theme is available here: https://www.b4x.com/android/forum/threads/b4a-v5-80-beta-is-released.63300/#content).
Sandman Expert Licensed User Longtime User May 16, 2017 #5 Erel said: It is better to explicitly decide whether you want a light or dark theme (code to set light theme is available here: https://www.b4x.com/android/forum/threads/b4a-v5-80-beta-is-released.63300/#content). Click to expand... Yes, I understand that I can change the colors in all kinds of ways, which is a very nice feature to have. But why does the Default text color for CheckBox (and the other reference views) change correctly and not the Default for ListView? Is it not an identical situation? (This is why I posted this as a possible bug.) ronell said: you can try... (code removed) Click to expand... Yes, I understand that I can do that. And, to take that reasoning to an extreme: I could make all my views from scratch by drawing on a canvas. But that's not what I tried to do. I just tried to slap a ListView on a Layout and let the OS render it using its defaults. It's a slippery path to go down if I code like you suggested. "If X then render like this, unless it's like that, in that case render like this" - it easily turns into am awful decision tree where I need to take a lot of responsibility when all I wanted was for the OS to just give me the vanilla, default version. Upvote 0
Erel said: It is better to explicitly decide whether you want a light or dark theme (code to set light theme is available here: https://www.b4x.com/android/forum/threads/b4a-v5-80-beta-is-released.63300/#content). Click to expand... Yes, I understand that I can change the colors in all kinds of ways, which is a very nice feature to have. But why does the Default text color for CheckBox (and the other reference views) change correctly and not the Default for ListView? Is it not an identical situation? (This is why I posted this as a possible bug.) ronell said: you can try... (code removed) Click to expand... Yes, I understand that I can do that. And, to take that reasoning to an extreme: I could make all my views from scratch by drawing on a canvas. But that's not what I tried to do. I just tried to slap a ListView on a Layout and let the OS render it using its defaults. It's a slippery path to go down if I code like you suggested. "If X then render like this, unless it's like that, in that case render like this" - it easily turns into am awful decision tree where I need to take a lot of responsibility when all I wanted was for the OS to just give me the vanilla, default version.
eps Expert Licensed User Longtime User May 16, 2017 #6 Are you setting the colour of any of the items in the ListView? What is your target sdk, in your manifest? You mention changing this, but you don't really need to... Have you targeted a theme? Upvote 0
Are you setting the colour of any of the items in the ListView? What is your target sdk, in your manifest? You mention changing this, but you don't really need to... Have you targeted a theme?
Erel B4X founder Staff member Licensed User Longtime User May 16, 2017 #7 In most cases the default color will indeed change based on the current theme. However this is not the case with ListView items. You can use CustomListView instead. The only reason to use ListView is if you want to show many (at least 1000) items. Upvote 0
In most cases the default color will indeed change based on the current theme. However this is not the case with ListView items. You can use CustomListView instead. The only reason to use ListView is if you want to show many (at least 1000) items.
Sandman Expert Licensed User Longtime User May 16, 2017 #8 Erel said: In most cases the default color will indeed change based on the current theme. However this is not the case with ListView items. You can use CustomListView instead. The only reason to use ListView is if you want to show many (at least 1000) items. Click to expand... Ah, I see, thank you. When I researched listviews last week I did indeed find CustomListView, and I did see you mentioning the size of the lists. But the ListView is built-in, and had this AddTwoLines method which was absolutely perfect for me. In the end I assumed this ListView was the most native of the two. (Especially since the other one was named "Custom".) Now I understand the situation and I know several workarounds, which is good. Can I still request an update in a future version of B4A that the ListView uses the OS default color? (Or should I post it as a formal Wish?) Upvote 0
Erel said: In most cases the default color will indeed change based on the current theme. However this is not the case with ListView items. You can use CustomListView instead. The only reason to use ListView is if you want to show many (at least 1000) items. Click to expand... Ah, I see, thank you. When I researched listviews last week I did indeed find CustomListView, and I did see you mentioning the size of the lists. But the ListView is built-in, and had this AddTwoLines method which was absolutely perfect for me. In the end I assumed this ListView was the most native of the two. (Especially since the other one was named "Custom".) Now I understand the situation and I know several workarounds, which is good. Can I still request an update in a future version of B4A that the ListView uses the OS default color? (Or should I post it as a formal Wish?)
Erel B4X founder Staff member Licensed User Longtime User May 16, 2017 #9 Sandman said: Can I still request an update in a future version of B4A that the ListView uses the OS default color? Click to expand... The default behavior cannot be changed as it will break the looks of existing applications. A possible solution is to allow setting the color to Transparent which will then be treated as the theme default color. I will check it. CustomListView is based on ScrollView. Upvote 0
Sandman said: Can I still request an update in a future version of B4A that the ListView uses the OS default color? Click to expand... The default behavior cannot be changed as it will break the looks of existing applications. A possible solution is to allow setting the color to Transparent which will then be treated as the theme default color. I will check it. CustomListView is based on ScrollView.
Sandman Expert Licensed User Longtime User May 16, 2017 #10 Erel said: The default behavior cannot be changed as it will break the looks of existing applications. Click to expand... I'm not going to argue with you. I'll simply note that changing behavior would (as far as I can tell) only affect these users: They target 24 or 25, and They expect the listview text to be unreadable ...which seems like an exceptionally small group. Upvote 0
Erel said: The default behavior cannot be changed as it will break the looks of existing applications. Click to expand... I'm not going to argue with you. I'll simply note that changing behavior would (as far as I can tell) only affect these users: They target 24 or 25, and They expect the listview text to be unreadable ...which seems like an exceptionally small group.