Office Hours — Today, October 16

Thursday, October 11

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!
how can I help you today?
Gabriele
Hi. :)
I can't understand one thing with my listview
4:00 PM
Gabriele
I've read that default background should be black, but if I don't put android:background="#000"
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
it will show whatever is behind it
Gabriele
Ah, so it's not black!
Mark M.
correct
with a dark theme, it will appear black, because that's the window's black background
with a light theme, it will appear white
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
you get Theme or Theme.Holo if you specify nothing else
(latter for API Level 11+, if your targetSdkVersion is set to 11 or higher)
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
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
if you take one of my ListView samples and run it, you will see that it renders correctly
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">
I'm using the default listview
Mark M.
your problem is in your row layout
what are you using for your row layout?
Gabriele
But I'm not doing it as a custom layout
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
somewhere in your app, you are calling setAdapter() or setListAdapter() to populate the ListView
the parameter to this method is an Adapter
Gabriele
View paste
listView.setAdapter(new ArrayAdapter<String>(oContext, android.R.layout.simple_list_item_multiple_choice,
				items));
I'm using the default one
Mark M.
there we go
it's possible that there's a bug in ActionBarSherlock or something that is fouling matters up
I don't think that I have used that specific combination
Gabriele
Ah, so maybe it's an issue of actionbarsherlock
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…
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…
it uses Theme.Sherlock
haven't tried it with Theme.Sherlock.Light.DarkActionBar
you might grab my sample, make that one change in the manifest, and run it
if mine works, then something else is afoot with your project
if mine stops working, that would suggest a bug in ABS
4:15 PM
Gabriele
Ok, I will try it then!
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
I mean, MAT as a tool for tracking down leaks
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
MAT is a tool to find memory leaks problem?
Mark M.
MAT will tell you what is in your heap
if there are things in your heap that you do not expect, it will tell you what is keeping them from being garbage collected
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
Oh, nice then
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"?
or guide lins
lines*
Mark M.
leaks are inevitably tied back to something with static scope
pretty much by definition
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
this stuff is probably covered in ordinary Java books and such, but as a chapter or section, not as an entire book
and, if you search online, you can probably find more
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 :(
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
IMHO
Gabriele
eheh
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
5:00 PM
Mark M.
turned off guest access

Thursday, October 11

 

Office Hours

People in this transcript

  • Gabriele
  • Mark Murphy