Kategorien
Android Computer / Informatik

ListView Divider Settings Order

Hey everybody,

today i experienced a little „problem“ with a ListView that i want to share with you.

I had a ListView defined in an XML layout file:

[sourcecode language=“xml“]

[/sourcecode]

For some reason i now needed to create it programmatically. So i did the following to create an equivalent ListView:

[sourcecode language=“java“]
ListView listView = new ListView(context);
listView.setDivider(new ColorDrawable(0));
listView.setDividerHeight(5);
listView.setVerticalScrollBarEnabled(false);
[/sourcecode]

But somehow the divider didn’t show up anymore. So what was the reason for that? It was just the order! Somehow setting the divider color after setting it’s height doesn’t work and the height is reset to 0. So changing the order to first setting the color and then setting the height fixed the problem!

Gr33tz Goddchen

[ad]

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert

Diese Website verwendet Akismet, um Spam zu reduzieren. Erfahre mehr darüber, wie deine Kommentardaten verarbeitet werden.