Office Hours — Today, June 14

Thursday, June 9

Mark M.
has entered the room
Mark M.
turned on guest access
Jun 14
4:00 PM
fitz
has entered the room
fitz
Hello
just picking up new books -
Mark M.
howdy, fitz!
remember: lift with your knees, not with your back
:-)
fitz
so summer finally hit bat area :)
Mark M.
"bat area"?
fitz
bay
Mark M.
ah
fitz
ya typing to fast :)
Mark M.
thought maybe it was a Giants reference
fitz
so - I hard that there are 4.5 billion cell phones vs 1 billion PC's - is that a true stat? you hear the same?
Mark M.
I've heard varying figures, but those sound roughly right
bear in mind that "cell phones" != "smartphones"
fitz
wow
Mark M.
more people in China, developing nations, etc. will have a cell phone than a PC
fitz
ya but that is amazing - so many people must just have cells and no PC's
4:05 PM
fitz
I have not looked into this at all but is it a recompile to get a localized version? or a ton more to it?
Mark M.
define "localized version", and what, specifically, you're localizing
fitz
language specific version
Mark M.
of what?
4:10 PM
fitz
does the phone handle language differences or do we code for it - IE English version, Chinese version etc.
Mark M.
OF WHAT? an app?
the OS itself?
something else?
Kathy
has entered the room
Kathy
Hello everyone.
fitz
app
Mark M.
howdy, Kathy!
fitz: you need to supply the strings
e.g., res/values/ for English, res/values-es/ for Spanish, res/values-de/ for German
Android then will use the right strings in the right cases
fitz
ok - just asking - when I get to that I will read up on it - thanks
Mark M.
Kathy: do you have a question?
Kathy
Yes, I want to create a custom button that when pressed parts of it will change color. What would be the best way to go about this.
Mark M.
um, I don't even know if that's possible
4:15 PM
Mark M.
the whole Button is either pressed or not
Kathy
Well, when you press a radio button parts of the button changes color, not all of it.
Mark M.
oh, I see
actually, the whole image changes
it just so happens they chose images where some pixels are identical
so, what base widget are you looking at for this: Button? ImageButton? CheckBox? RadioButton? ToggleButton? something else?
Chris
has entered the room
Mark M.
howdy, Chris!
Chris
Yo
I'll have a question in a little bit.
Mark M.
OK
Kathy
I think probably a radio button since only one can be chosen at a time. I am flexible on this.
Mark M.
OK, you need to replace the StateListDrawable that is used for the RadioButton button image
that is defined in btn_radio.xml in your SDK resources
it points to a series of PNG images based on density
you'd copy all those into your project and modify the PNGs to suit
then use setButtonDrawable() to associate it with the widget
4:20 PM
Mark M.
to be more specific, "to associate your custom btn_radio.xml, as R.drawable.btn_radio, with the widget"
Kathy
Thank you, that is very helpful. If I decided to do an imagebutton, what would be my approach?
Mark M.
well, if you're looking for "click the widget, and the image changes" behavior, I would not recommend an ImageButton
though, you could use it and just call setImageResource() to replace the image in the foreground of the button
actually, ImageButton isn't too bad for that, I guess
Kathy
I want them to click the button, not necessarily in a list and go to another screen when the button is clicked.
Mark M.
then they'll never see the image change, no matter what the widget is
why are you worrying about changing the image?
let me take questions from the others, and I'll circle back to you
Chris: are you ready for your question?
4:25 PM
Kathy
I have an image that when pressed will change color. For example a flower shape and when the flower is pressed as part of the button, the flower would turn pink.
Chris
Not yet. I'm trying to eat some lunch and take care of something but I'll be ready in a few minutes. I just wanted to join because if I didn't I'd forget and it would be time to go home.
Mark M.
Kathy: but if as soon as they touch the button, they "go to another screen", they will never tell that the flower turns pink
ah, OK
fitz: do you have another question?
fitz
not for now thanks
Mark M.
Kathy: OK, we can continue if you have further questions
fitz & Chris: chime in if you want to ask a question
Kathy
View paste
I just started playing around with listviews.  I want the screen to have some text view and image kind of stuff at the top and bottom and I want something like 
radio buttons for each item in the list. what would be the best way to do this?
Chris
I'm composing my question because it's long :)
4:30 PM
Chris
But the answer will probably be simple.
Mark M.
Kathy: If you make the ListView have android:choiceMode="singleChoice" and use a CheckedTextView for the rows (or make the rows support the Checkable interface), you get radio buttons on each row, on the right
kinda like you see in various list dialogs
or, if there will only be a couple of RadioButtons, put them in a RadioGroup and the RadioGroup in a ScrollView
Kathy
Okay, thanks, I will try that. Thank you so much.
4:35 PM
Chris
OK, you may not remember, but last time I asked about the max connections for the HttpClient and you said you usually don't see that being manually set so I took that out and everything works fine. So I'm just learning and kind of flailing around. Right now my app logs in to a the server and displays a list view of organizations that a user can access. They select and org and then it displays inventory objects like virtual machines, networks, etc. I'm not sure the best way to handle working with the listview. So when someone selects an item from the list it will query the server with the item's href. So the href needs to be assosiated with the item that was selected. At first I just had two arrays. One for the item and one for the href and then I would index them in the onClickListener, but that seemed dumb. So this time I created a class like VM with two functions: getName() and getHref(). Then I build a list of these objects and pass it into the listview. Then I use that setTag() to the view so later on in the onClickListener I can use getTag() and then like getHref(). Does that seem OK?
I was also thinking of storing the inventory items in a database and using that with cursor adapter
Mark M.
you don't need setTag()/getTag() for the ArrayAdapter/ArrayList scenario
when the user clicks an item, the position parameter is the index into your ArrayList
or, call getItem() on the ArrayAdapter
whether or not you should store the stuff in a database depends on whether or not you need to persist the info (e.g., offline access)
if you need to fetch it every time regardless, no sense in spending cycles on file I/O
4:40 PM
Chris
Hmm I'll look into the getItem(). I'm going to bring up my project to see why I thought I needed setTag()
oh my goodness.
OK, I see :)
I was like man that doesn't seem right.
Mark M.
with ListView, getTag()/setTag() are mostly used for findViewById() lookup caching
if anything at all
Chris
Yeah I remember seeing that in one of your books and thinking that I bet I'm not using it correctly.
OK, you've answer that question. Someone else can go.
Mark M.
at this point, it's pretty much a free for all
if anyone has a question, chime in
Chris
This isn't really a question, but I messed up my sdk and downloaded a new version and when I run the emulator it's real big and ridiculously slow. It used to be about the size of my phone and fast.
4:45 PM
Mark M.
you probably created an AVD for Android 3.0 or 3.1, which are designed for tablets
Chris
I use the snapshot feature and I guess it's OK once it gets up and running but I like the old one a lot better but no idea what type of config it had :(
Mark M.
for a phone-sized one, create an AVD for 2.2 or 2.3
the emulator speed is driven mostly by emulated screen size, which is why the tablets are so much slower
Chris
Well it's shaped like a phone but like 8" tall haha
I'll check though.
OK, I want to know how to make menus like in the Google music app.
Like you select an item and it expands to show you more items.
What should I look into for that?
fitz
question - if I have a gmail account set in phone - can my app access that user info to slice a dice info in my app - providing the user give my app permission? or do I need to create a settings function in my app
Mark M.
Chris: you mean like in the Artists tab, where entries fold out underneath the artist name for each album?
that's ExpandableListView
fitz: I do not know
Chris
Yep, okay thanks.
fitz
ok
Mark M.
I would have hoped that your question would have been covered in that "using Google GData APIs from Android" I|O presentation
which I haven't watched yet
fitz
cya have a great day
Mark M.
see ya!
fitz
has left the room
4:50 PM
Kathy
Goodbye all, thanks for the help and patience.
Mark M.
have a pleasant day!
Chris
Mark, I don't have anything else right now.
Thanks a lot.
Mark M.
happy to help!
Chris
later
Chris
has left the room
5:00 PM
Mark M.
have a nice day, everyone!
Kathy
has left the room
Mark M.
turned off guest access

Thursday, June 9

 

Office Hours

People in this transcript

  • Chris
  • fitz
  • Kathy
  • Mark Murphy