Office Hours — Today, February 26

Tuesday, February 23

Feb 26
9:55 AM
Mark M.
has entered the room
Mark M.
turned on guest access
10:05 AM
Mike Q.
has entered the room
Mike Q.
Hi Mark...light day today huh?
Mark M.
Howdy, and yes
Tuesday was a no-show
Wondered if the Campfire link was busted or something
Mike Q.
Ha!
Well I have a question regarding MapView.
Mark M.
Fire away
been dealing with MapView a fair bit in recent days myself
Mike Q.
I was looking at your tutorial and was able to get a map fired up from my application....
I set the setBuiltInZoomControls to true and I'm not seeing anything on the map. Am I missing something?
10:10 AM
Mark M.
tap towards the bottom of the screen
Mike Q.
Ok, I'm firing up the app now. I did "tap" all over it in the emulator and didn't notice anything but let me try again.
Mark M.
bottom center should do it
Mike Q.
Also, I added a default overlay to the map. I thought that would also pinpoint where the location was on the map by default and yet it seems to do nothing.
Mark M.
I'm assuming this is a reasonably recent Android environment (1.5+), right?
What is "a default overlay">
Mike Q.
Just did this:
View paste
private void addOverlay() {
		overlay = new MyLocationOverlay(this, map);
		overlay.enableMyLocation();
		map.getOverlays().add(overlay);

	}
Mark M.
That will show your location if you are on the map
If this is an emulator, you'll need to supply a fix, I imagine
Mike Q.
Ok, well I did touch toward the bottom on the emulator and you are correct, the zoom controls were there. However, I don't see anything from the overlay.
Mark M.
Emulator or device?
Mike Q.
Emulator.
Mark M.
Did you feed a fix to it that is within the bounds of the map via DDMS or something?
10:15 AM
Mark M.
MyLocationOverlay will not change the map center, just highlight your location
Mike Q.
No, I simply passed a GeoPoint to the map and it does bring me to that area within the zoom level but nothing pinpoints the specific location.
Mark M.
It's possible it only works on hardware nowadays
Mike Q.
Ah, ok, I guess I'll need to deploy it to the device and see what happens.
So speaking of the emulator.....
Do you know if there's a way to have it actually "emulate" a device in regard to performance/memory constraints?
For instance, we're parsing a large XML doc and it performs very well on the emulator on my machine but I assume it can take advantage of the full processing and memory from my workstation.
Mark M.
Actually, I tend to find the emulator runs slower than actual hardware
The emulator has to convert from ARM opcodes to Intel
Mike Q.
Really????
Mark M.
Also, emulator lacks graphics hardware acceleration
10:20 AM
Mike Q.
Wow, well that
s good news.
Mark M.
I can play video back better on a G1 than I can on an emulator running on a quad-core 2.5GHz with a fairly nice video card
Mike Q.
That's very good to hear.
Mark M.
However, to get back to your original question...
-cpu-delay <delay> will provide a slowdown of the emulator CPU
and I think there may be a config file setting you can use to control the RAM, but I'm not 100% certain
Mike Q.
Cool, I will try that. Thanks.
Mark M.
BTW, speaking of MapView, the next edition of the Advanced Android book will have an "Interactive Maps" chapter
10:25 AM
Mark M.
coverage of how to do pop-up panels, how to have different drawables for different points on an itemized overlay, perhaps more
Mike Q.
That sounds good. When will that be coming out?
Mark M.
2-3 weeks, I imagine
Mike Q.
Great, I'll look for that.
10:30 AM
Mike Q.
Mark, let me throw one more thing out there....
Mark M.
go ahead
not much of a queue today
Mike Q.
Ok, I have a couple of lists and in one of them I have a button in each list item and in the other I have an image in each list item.....
The only way I've found to add event handlers to each item in the list is by using the OnClick property in the layout for the row. That is working fine but that wasn't supported until version 1.6.
Mark M.
Each item in which list?
10:35 AM
Mark M.
And does "item" mean "row"?
Mike Q.
Yes.
Sorry, I guess I could be more clear here.
So each row in the list has a button in it.
I need an event handler on those buttons.
I have a layout for each row in the list.
In the XML layout for the row, there's an OnClick property on the button.
I add a click handler there, but I can't figure out how to add it programmatically to each button in each row in the list.
Hope this makes more sense.
Mark M.
Follow the recipe outlined in the Fancy ListViews chapter of the Android book
I.e., create your own adapter class and inflate the rows
Then, you can get your hands on the Button and call setOnClickListener() for each row you inflate
10:40 AM
Mike Q.
Ok, I thought that might be the case. I was trying to avoid writing my own adapter class. Thought there might be a shortcut I was misssing that I could still use SimpleAdapter and still do this.
Mark M.
I haven't used SimpleAdapter much
Mike Q.
It seems easy enough to use. I see my situation definitely leaning more toward needing to use custom adapters though.
One last quick thing.....is there really a lot of overhead using findViewById()?? I read somewhere there was. Someone making the case for using a "holder" pattern, but I haven't seen any performance issues with this.
Mark M.
Well, I cover that in the Fancy ListViews chapter as well
There is some overhead
For a really long list the user flings, it'll add up
Smaller lists, it won't be a big deal
10:45 AM
Mike Q.
Ok, maybe it was in your book that I read that. It all blurs together anymore! :-)
Well thanks for your time today Mark. Gonna go shovel some snow!!!
Mark M.
yeah, that's on my agenda too
Mike Q.
Have fun!
Mike Q.
has left the room
10:55 AM
Mark M.
turned off guest access

Tuesday, February 23

 

Office Hours

People in this transcript

  • Mark Murphy
  • Mike Q