Oct 16 | 3:55 PM |
Mark M. | has entered the room |
Mark M. | turned on guest access |
Gabriele | has entered the room |
Mark M. |
howdy, Gabriele!
|
Mark M. |
how can I help you today?
|
Gabriele |
Hi. :)
|
Gabriele | |
Gabriele |
I can't understand one thing with my listview
|
Oct 16 | 4:00 PM |
Gabriele |
I've read that default background should be black, but if I don't put android:background="#000"
|
Gabriele |
the background is not black and text becomes unreadable on emulator and on my motorola xoom, too
|
Mark M. |
the default background of a ListView is transparent
|
Mark M. |
it will show whatever is behind it
|
Gabriele |
Ah, so it's not black!
|
Mark M. |
correct
|
Mark M. |
with a dark theme, it will appear black, because that's the window's black background
|
Mark M. |
with a light theme, it will appear white
|
Mark M. |
and if you have the ListView above something else on the Z axis, it will be whatever the "something else" is
|
Gabriele |
So I can make it appear as default, byt applying a theme to my activity?
|
Mark M. |
well, everything has a theme
|
Mark M. |
you get Theme or Theme.Holo if you specify nothing else
|
Mark M. |
(latter for API Level 11+, if your targetSdkVersion is set to 11 or higher)
|
Mark M. |
if you specify a theme, whatever the color scheme
of the theme is will control the window, and hence what is behind a
typical ListView
|
Gabriele |
The thing that I don't understand is why by
default Theme or the default one I'm using doesn't make the text
readable, is this a bug of android, or an error of my code? Or I can't
assume that the default theme makes my text readable?
|
Mark M. |
if you do not mess with *any* colors, the text will be readable
|
Gabriele |
Because, I thought "Not saying it, I'm using the default theme"
|
Mark M. |
most of my samples do not specify a theme, or one that inherits just about everything from a stock theme
|
Gabriele |
I'm not doing anything, but it's not readable!
|
Mark M. |
and everything is readable
|
Oct 16 | 4:05 PM |
Mark M. |
but once you start fiddling with colors of, say, a
TextView, then you can get yourself in trouble and need to make sure
that everything synchronizes
|
Mark M. |
if you take one of my ListView samples and run it, you will see that it renders correctly
|
Mark M. |
you need to then determine what you are doing
differently, in your row layouts or whatever, that is causing the
difference in behavior
|
Gabriele |
This is what I see by default: http://tinypic.com/r/33er0vo/6
|
Mark M. |
what are you using for your row layout?
|
Gabriele |
In my manifest I have: android:theme="@style/Theme.Sherlock.Light.DarkActionBar">
|
Gabriele |
I'm using the default listview
|
Mark M. |
your problem is in your row layout
|
Mark M. |
what are you using for your row layout?
|
Gabriele |
But I'm not doing it as a custom layout
|
Oct 16 | 4:10 PM |
Mark M. |
I cannot help you if you will not tell me what you are using for your row layout
|
Gabriele |
What do you mean?
|
Mark M. |
just paste in your adapter constructor or something
|
Mark M. |
somewhere in your app, you are calling setAdapter() or setListAdapter() to populate the ListView
|
Mark M. |
the parameter to this method is an Adapter
|
Gabriele |
View paste
|
Gabriele |
I'm using the default one
|
Mark M. |
there we go
|
Mark M. |
it's possible that there's a bug in ActionBarSherlock or something that is fouling matters up
|
Mark M. |
I don't think that I have used that specific combination
|
Gabriele |
Ah, so maybe it's an issue of actionbarsherlock
|
Gabriele |
No, if I remember good you've used the android default one in this example
|
Mark M. |
yes, though probably with a dark theme
|
Gabriele |
Because there was an example with the SINGLE and with MULTIPLE_MODAL (which isn't supported by sherlock)
|
Mark M. |
yes, I am not specifying a theme in https://github.com/commonsguy/cw-omnibus/b…
|
Mark M. |
oh, you are doing the action mode stuff
|
Gabriele |
yes, exactly
|
Mark M. |
my manual action mode sample is https://github.com/commonsguy/cw-omnibus/b…
|
Mark M. |
it uses Theme.Sherlock
|
Mark M. |
haven't tried it with Theme.Sherlock.Light.DarkActionBar
|
Mark M. |
you might grab my sample, make that one change in the manifest, and run it
|
Mark M. |
if mine works, then something else is afoot with your project
|
Mark M. |
if mine stops working, that would suggest a bug in ABS
|
Oct 16 | 4:15 PM |
Gabriele |
Ok, I will try it then!
|
Gabriele |
I have another question, which isn't related to
android too much, do you have a "good" resource, book or something, (I
know you hate defining it good!) related to memory leaks?
|
Mark M. |
not really
|
Mark M. |
I mean, MAT as a tool for tracking down leaks
|
Mark M. |
but if you mean written words about tracking down leaks, I cannot think of any particular resources off the top of my head
|
Gabriele |
Because one or two week ago, you've talked me
about the problem of using static data members and reading on google,
I've found something, anyway I'm scared of producing bad code
|
Gabriele |
MAT is a tool to find memory leaks problem?
|
Mark M. |
MAT will tell you what is in your heap
|
Mark M. |
if there are things in your heap that you do not expect, it will tell you what is keeping them from being garbage collected
|
Mark M. |
there's a chapter on MAT in _The Busy Coder's Guide to Android Development_
|
Gabriele |
Ah, so I can do something like instantiate many times and check if there is something I would not expect
|
Gabriele |
Oh, nice then
|
Oct 16 | 4:20 PM |
Gabriele |
But, how have you learned to avoid leaks? I mean,
the tool is a good thing because sometimes it's hard to find them, but
is there some "guide to avoid leaks"?
|
Gabriele |
or guide lins
|
Gabriele |
lines*
|
Mark M. |
leaks are inevitably tied back to something with static scope
|
Mark M. |
pretty much by definition
|
Mark M. |
so, being careful with your own static-scope data members is important
|
Gabriele |
For example you said I shouldn't use (most of the
time) static data members, but where I can find other advices like this
you told me?
|
Mark M. |
similarly, being careful with other things that
live a long time (e.g., a thread) or for the process lifetime (e.g., an
Application) are important
|
Mark M. |
this stuff is probably covered in ordinary Java books and such, but as a chapter or section, not as an entire book
|
Mark M. |
and, if you search online, you can probably find more
|
Mark M. |
for me, I have been working in Java for over a
decade, so I do not refer to those resources very often, and what I
*did* use way back when is probably long gone (and certainly forgotten)
|
Gabriele |
I've searched it in some books like Deitel one and others, but there 3 lines (when you're lucky) talking about leaks :(
|
Gabriele |
It seems that all books learn you how to do a lot of things but nobody talks about what to not do!
|
Mark M. |
that is pretty much the case for any technology topic
|
Mark M. |
IMHO
|
Gabriele |
eheh
|
Oct 16 | 4:25 PM |
Gabriele |
Just for curiosity, did you do something on iOs,
too? What do you think about it? I'm taking advantage of the time
because there is no other, but you're free to don't answer, obviously
|
Mark M. |
no, I have not done any development for iOS
|
Gabriele |
I see. Anyway your book is really good, one of the best programming book I've read
|
Mark M. |
thanks!
|
Gabriele |
Now I'm going to do the test with your sherlock
example and searching some book related to java memory leaks TT thank
you very much!
|
Mark M. |
you are very welcome!
|
Gabriele |
Bye. :)
|
Gabriele | has left the room |
Oct 16 | 5:00 PM |
Mark M. | turned off guest access |