While delving further into Android, I’ve been creating a “hello world” type of app – its not as complex as what MahTweetsMobile will be, but it is encompassing a lot of different elements (custom ListAdapter, SQLite for persistent storage, different types of menus, loading external intents, etc).
One “difficult” element has been events. I say “difficult” because by design, its freaking nuts.
Scenario
I’ve got a custom ListViewAdapter, for my custom list elements, where the ListView items include a checkbox. This checkbox is to indicate the status of the items (for reference, its a shopping list app, you tick the checkboxes to show which items you’ve bought while shopping, the items then go grey in colour).

I wanted to add a “long press” context menu so that you could easily bring up a menu (with options such as Edit Item or Delete Item)
The Problem
Normally when “attaching” event listeners with ListViews, you use setOnCreateContextMenuListener on the ListView itself. You then override your Activity’s onContextItemSelected, figure out what menu button was pressed as well as what item it was pressed on.
ListView x = (ListView)findViewById(R.id.ListView01);
x.setOnCreateContextMenuListener(new OnCreateContextMenuListener()
{
public void onCreateContextMenu(ContextMenu contextMenu, View view,
ContextMenuInfo arg2)
{
contextMenu.add(0,CMENU_DELETE, 0, "Delete Item");
}
});
public boolean onContextItemSelected(MenuItem item)
{
AdapterContextMenuInfo menuInfo =
(AdapterView.AdapterContextMenuInfo)item.getMenuInfo();
switch (item.getItemId())
{
case CMENU_DELETE:
//Use menuInfo.position along with the adapter.getItem
//ie Product p = (Product)adapter.getItem(menuInfo.position);
return true;
}
return true;
}
As you can see, its ugly code, but it works. Sort of. The problem was the checkboxes.
As soon as you add checkboxes to the individual items view, any listener created on the ListView never fires – the CheckBox swallows the event!
The Apparent Solution
Apparently this is a known bug (or more accurately, this is by design!). The solution is to set the event handlers on the rows themselves; inside the custom ListAdapter, when you’re inflating the various UI elements – look at my previous post on Custom ListAdapter, it’s under the getView method – on that “rowLayout” use the same setOnCreateContextMenuListener as the code used on ListView above, except only apply it to the individual row’s.
That would be fine if you didn’t care which item was pressed. That’s right, the cast to AdapterContextMenuInfo of item.getMenuInfo() in your Activity’s (yes, your activity has to override this, nowhere else works. argh!) onContextItemSelected always returns null because item.getMenuInfo() is always null.
The Actual Solution
I have no idea how I stumbled across this solution – I think I was in the process of undo-ing lines of code to try and figure out “where I’d gone wrong”.
Fact: To get the event to fire with checkboxes you need it to be set on the rowLayout.
Fact: To get menuInfo to be anything other than null (ie, tell you where it came from), you need it set on the ListView
Solution? Combine them. Wait, what? Two event listeners to get them to work? Yup.
On the rowLayout, set the listener:
rowLayout.setOnCreateContextMenuListener(new OnCreateContextMenuListener()
{
public void onCreateContextMenu(ContextMenu contextMenu, View view,
ContextMenuInfo arg2)
{
}
});
Notice the lack of code inside the onCreateContextMenu? Well, any ContextMenu items added inside this method won’t have AdapterContextMenuInfo – so don’t set anything, no menus will appear.
Now also set the adapter on the ListView using the code above.
Now it all works. WTF doesn’t begin to describe this.
Disclaimer: I’m new to Android, I could be doing this all wrong. If I am, please comment and correct me.
Programming for Android is an interesting experience, coming from a .NET/C# background. I’ve done plenty of Java before in Uni and disliked it, but that was before I started playing with WPF.
Like WPF, Android’s UI is created using XML based documents, but unlike WPF, there aren’t any nice WYSIWYG builders. And most of the time it seems you need a combination of code behind and XML to get what you want for the UI, which can get a bit frustrating.
The divider between the items in this particular app is more annoying than it is useful, so I wanted to get rid of it. I was initially looking for separator or border, but the name is divider, and it has two properties.To set the divider between the ListItems to "nothing", you have two options. The first is in Java,
ListView x = (ListView)findViewById(R.id.ListView01);
x.setDivider(null);
x.setDividerHeight(0);
The alternative is to set it in XML, but in this case its more of a hack than the above of turning it ‘off’.
<ListView
android:id="@+id/ListView01"
android:background="#ffffff"
android:dividerHeight="0px"
android:divider="#ffffff" />
Even though the dividerHeight is set to 0 (0px, 0dp, whatever, the results were the same), a black line was still visible. The best solution is to set the colour (the divider value) to the same as your background. Using a gradient or image as the background? Set it in the code behind.

It is undeniable that Microsoft’s Xbox Live Gaming service is regarded as pretty damn good – it has something like 17 million members, and all games on the Xbox 360 integrate into with it.
In the PC world, the bastard cousin of Xbox Live, Games For Windows Live (GFWL), has not fared so well. Only a handful of games make use of the service, and those that do usually suffer because of it. Original adoption of GFWL was always going to be poor – the service launched as a paid subscription service for both the developers and the end user – and in the PC world known for free gaming, that just wasn’t going to cut it. Thankfully late last year with the release of GFW v2, it was made free for both developers and end users – who now get access to all features (like the theoretical-but-in-reality-non-existent Xbox360 <-> PC gaming).
So why has GFWL still fared so poorly despite now being free? Because there is no value to it. I should clarify that. There are features offered by GFWL, but they don’t equate to much because of how poorly implemented or supported they are. The features offered by GFWL are:
- In the few games that support GFWL, you can talk to your “LIVE” friends. Don’t confuse these with the same friends on Live Messenger, that is a completely separate and isolated service.
- Achievement tracking
- Marketplace
In the desktop (or "out of game") client all you can do is connect to the marketplace – it is a glorified web browser. However there is so little content there is no reason you’d use the GFWL marketplace – seven demos, videos of games, and a few addons (although five of those are for Fallout!) You can’t purchase full games – there is no reason to use this over Steam!

The above screenshot is the login screen for the desktop GFWL client – look familiar? It should, it looks like the Windows Live Mesesnger login screen with a different skin applied to it. Surely this desktop client lets you talk to your LIVE friends? Nope! What about at least add/remove friends? Nope! The only way you can manage your friends is through a webpage (www.xbox.com) or through an XBox or XBox 360.
The isolated nature of LIVE friends and Live Messenger contacts lets far inferior chat networks/clients such as Steam or Xfire take over (inferior in terms of people on the networks and chat client features such as logging and less uglyness)
What Microsoft needs to do so that this is no longer taken as a joke is
- Turn the desktop client into more than a glorified browser – make it a chat client too.
Until you can talk to your LIVE friends at the desktop, the benefits of GFWL in game are also reduced.
- Make the desktop client also talk to Messenger network and Messenger network talk to the "LIVE" network
If the two clients talked to the same networks, you could choose what IM client you wanted to use (ie, a gamer-centric client, or a general chat client). Perhaps the gamer-centric client could do in game overlays ala XFire/Steam (but not require them to be GFW/GFWL titles)
- Get some content
Chicken and egg situation – not going to get the content there until it has the userbase, but the userbase is never going to move from Steam or other systems unless the content is there (which is why Steam had such a hard time when it started up).
With yesterdays launch of the Zune HD’s and the new Zune Software (4.0), it didn’t take me long to realise everything I hate about Microsoft can be summed up by using Zune examples.
1. Stupid region restrictions
Neither Zune HD or regular Zunes are for sale outside North America. Likewise, the Zune Pass isn’t available outside of NA. I know plenty of people who would drop their iPod for a Zune and the Zune pass, the music subscription model is an awesome idea, and the Zune HD is some awesome looking hardware.

I know the above is the factually correct representation of the world, but I really wish us dragons could give them money on a monthly basis so we could listen to various monster rock songs.
2. Bloatware
iTunes, 89meg; Songbird, 13.3meg, WinAmp, 9.8meg… Zune Player? 131meg – and it comes in x86 and x64 separate downloads. In typical fashion, Microsoft just have to have the largest program available. Why is it so big when most of it is visualisations and data pulled from the web? That brings me to my next gripe..
3. Custom UI framework – not WPF
Why is the Zune Player 131meg? Probably because they’ve implemented their own private UI framework based on Media Center rather than using Windows Presentation Foundation (WPF), the framework we are constantly reminded of being "good" for media and the like.
WPF is supposed to be the successor to WinForms in .NET. It can use vectors for the interface, has hardware accelerated support, pixel shader support for effects… but where has Microsoft used it? Well, there is Expression Studio (a suite of applications for… making WPF/Silverlight apps) and the unreleased Visual Studio 2010 (…a program for developing WPF/Silverlight apps amongst other things)… I can’t think of any other examples.
The apparent lack of faith in their own framework leaves us WPF developers scratching our heads and wondering if we should be calling it quits on WPF, or striving on when they finally iron out a considerable number of the show stopper bugs (virtualisation problems, resize performance problems, text blurry problems) in .NET 4.0 (or possibly later!)
4. Overlapping Products
Instead of being content with just one media/music playing application, Microsoft have decided to reinvent the wheel and have two separate programs. Zune Player and Windows Media Player (WMP). It’s be great if the features in Zune Player were a super-set of those found in Windows Media Player 12, but it lacks a host of features found in the latest (and even some found in the previous) version of WMP.
| |
Zune Player |
Windows Media Player 12 |
| Handles multi-disc albums |
Yes |
No |
| Has DNLA Support |
No |
Yes |
| Has Windows 7 Support |
Yes |
Yes |
| No, really, Win7 support including Libraries |
No |
Yes |
| DVD Support |
No |
Yes |
| Detects Folder.jpg |
Sort of |
Yes |
| Detects folder.jpg hidden by WMP |
No |
Yes |
| Syncs Zune |
Yes |
No |
| Syncs other mp3 devices using MTP |
No |
Yes |
| Has "similar song/artist" playlist |
Yes (Smart DJ) |
No |
| Has "autoplaylist/smart playlist" |
Yes |
Yes |
| Plays Internet Radio playlists |
No |
Yes |
| Has taskbar mode |
Yes |
No (But WMP11 did) |
| Search-as-you-type |
No |
Yes |
| Podcast support |
Yes |
No |
The above shows that unless you really want the pretties or the few features WMP is lacking, there isn’t much in the way to convince me to use the Zune player.
I decided to upgrade my HTPC to Windows 7 Release Candidate today, and it all went very smoothly – about 15-20minutes from reboot, through install, and being at the desktop. I needed to grab my TV tuner drivers, but everything else was picked up and working – fantastic!
My HTPC is "powered" by an Intel G45 (x4500HD), which boasts a ‘powerful video engine provides users with a rich, new media experience to deliver smooth HD playback without the need for add-in video cards or decoders’. It also mentions stuff about Bluray playback, so it sounds perfect for building a HTPC with, right?
That would be all good if it was true… but when I tried to play back any of the high def stuff I have encoded in h.264, WMP informed me that there was something wrong with my graphics card! Then I started noticing other artifacting in Windows obviously caused by the graphics card.
I decided to hunt down the latest Intel WDDM 1.1 (that’s what Windows 7 uses, after all), only to discover Intel have not made any WDDM 1.1 drivers available for download. Argh! It’s a good thing they would have had no idea that Windows 7 was coming out, otherwise we’d be able to blame Intel… oh wait!
Given Intel move at glacial speeds, there is no way I can even hope that Intel will have drivers out (that work!) by the time Windows 7 is finalised and goes on sale. I’m going to buy another graphics card for the HTPC. So dear reader(s) – any suggestions on a passively cooled NVIDIA or ATI video card for my HTPC, going for under $70AUD?
"Pocket Video Cameras" seem to be gaining momentum, much the way netbook computers did. I’ve even seen some people call them "netcorders" partially in reference to how the first generation’s resolution was "perfect" for YouTube (some even had said logo plastered all over their packaging), and partially how they’re small, lightweight and cheap (typically under $200USD) – all the advantages a netbook has over a laptop.
Despite really only being launched this year, pocket video cameras have entered their second generation, now with models touting 720p recording, such as the Creative Vado HD, Flip Mino HD or my preference Kodak Zi6.
The Zi6 is different from the two other models – it uses removable storage (SDHC, up to 32gb) and removable standard AA batteries. The others use non-removable (but obviously included with) onboard flash storage (4gb for the MinoHD, 8gb for the VadoHD) and (I think) non-user replaceable lithium ion batteries (which to their credit, give about 2 hours recording per charge)
Well, none of these models are in Australia. Heck, Pure Digitals (they sell the Flip) don’t sell anything in Australia from what I can see. I contacted both Creative and Kodak via their websites
Creative’s response?
As regards to your enquiry, I understand your interest in getting our New Vado HD.
As the product are new in the market, it is not widely available in other region yet.
Do visit http://au.store.creative.com/ regularly for the stock availability updates.
In case if you need any clarification, please do not hesitate to contact us.
Helpful. The first generation Vado is already available in Australian stores, but not on Creative’s online store. Yeah, I’ll keep checking back there. Cough.
Kodak were a little better, their live chat/help system gave me a general number to call, but unfortunately they gave a response of "it’s not out now, and head office has given us no information about it".
Where does Twitter fit into this? Well I asked the Twitterverse to help me to get in contact with Kodak and/or Creative in regards with the two cameras…and I’m now being followed by about four Kodak-ians! Within half an hour Gord Weisflock was able to give me a number and name in the Melbourne offices of somebody who could help me out with Australian availability – another fantastic example of the power of Twitter.
Unfortunately, the Kodak Zi6 will not be coming to Australia at all. (Official response was Kodak Australia will not be launching the Zi6, but will be launching the Zi8 sometime around March 2009) If the camera was coming to the country I would have waited for it simply because of the awesome response from the Kodak team over Twitter, but as it isn’t and I can’t seem to dig up anything on the Zi8, if I want to buy locally I will have to jump ship to Creative.
Looks like it’s back to waiting or importing for me :(

Will Wright’s (of SimCity and The Sims fame) Spore was released on September 4th, a game I’ve been eagerly awaiting since seeing demonstration videos of the game back in 2005. I must admit I’ve kept myself out of the loop, so that the anticipation and inevitable long wait didn’t kill me. Unfortunately it wasn’t until after ‘completing’ the game that I learnt it was designed for the casual gamer (in other words, its an extremely shallow, cutesy and repetitive game). ‘Completing’ is something you can never do for Wright’s games it would seem (being all sandbox games essentially), but I use the term in sense of ‘done-anything-I-was-going-to-do-in-the-game-and-have-now-uninstalled-it’.
Most of my gripes are particularly with the Space Age, because that is where the majority of the game is situated (as it only took two hours to progress through spore, creature, tribal and civilisation stages combined). During the Space Age, the game tries to do too much and unfortunately it can’t pull it off with the shallow/basic gameplay route. If you can get past the tedious nature of being the universes defender against biological disasters and the occasional pirates which steal spice one unit at a time, Spore presents a very basic trading game. There is no way to tell who you’ve visited or sold to in the past, no way to predict what they’ll pay for your spices on the next trip, and the only way to see is to fly into their solar system and around their planet – urgh! Oh yes, you’re supposed to be wowed at the supreme power you wield to terraform a planet, but the only reason you do that is to generate more spice to trade. The excitement of terraforming a world and building a new slave factory colony is diminished when all you have to do is hold down the left mouse button after selecting the appropriate tool.
While you’re conquering the universe in the name of…well whatever you named your Empire, you’ll often get called back to ‘duty’ to prevent a planets ecological disaster. Oh dear, a nuclear accident? A planet hurtling dangerously close to a sun? A meteor on its way? No. Some animals mutated/got sick, they now have glowing tails, and you have to kill the five mutants (it always seems to be five) before they infect the rest of the species and they become extinct; failure to do so will repeat the process slowly eliminating all creatures from a planet. That’s the best they could come up with? It wouldn’t be too bad if you weren’t either asked to do that for your empire and all your allies or recalled thousands of light years away, through several worm holes away during the middle of large scale battles.
Speaking of space battles, as you start off you are in an understandably weak vessel with limited weaponry, but as the game progresses you can buy new weapons as well as upgrade existing ones. The problem is, only one enemy race seems to have weapons that can approach or rival yours and even then its limited to their spacecrafts – their cities can be wiped out with a single bomb (MegaBomb, doesn’t cost anything to use) making combat quick and easy, you spend most of the time scrolling in and out of solar systems.
With the amount of grinding (eliminate this set of creatures, abduct that alien/plant, scan this surface) in the game, it just feels too much like a single player MMORPG. Perhaps I was just expecting too much from Spore, at the end of the day I really just wanted less Sims-in-Space, and more SimCity-on-a-universal-scale.
TechED 08 was my first TechED, so I only have accounts from others of how previous years have gone down, however it was pretty easy to see that this year was far from smooth sailing. I think the key point to remember in this rant is that the cheapest of tickets were over AUD$1000, which doesn’t include flights and accommodation. When you are paying those sort of amounts, there are certain expectations about the general experience of the event.
Tech Fails
- The network was fail. Wifi often wouldn’t connect at all, when it did the net connection was incredibly flakey, so many ran to wired connections only to find they occasionally died too!
- RFID is a wonderful idea, but this was clearly a horrible implementation. I heard accounts (on day one) of the RFID counter detecting 6 people in a room of 50. The only time I saw the "in-room-RFID-stats" working (for lack of a better word), it had people leave the room dozens of times…while sitting or standing in the middle of the room.
Food Fails
Food is probably one of the hardest parts of such a large scale event to get right, but TechED 08 was a shining example of how to stick your foot in your mouth.
- Some food was served cold, despite clearly meant to be served hot (best example that springs to mind was the Fried Chicken at the closing party) – this wasn’t a matter of how long it’d been sitting out in the room, the tray was replaced right in front of me!
- Drinks were a rare resource to come across, you could see some thinking "he who controls the
spice drink, controls the universe TechED". Okay, perhaps a little over dramatic, but the point remains. While there were drinks fridges posted all over the centre, they were emptied by the end of the first session of the day and seemingly only partially restocked overnight.
Similarly, there were water coolers everywhere but they too were often emptied, rarely switched on, and perhaps the worst offense of all was that there was no cups to pour water into! Delegates were given water bottles (with their backpacks upon registration), but speakers, staff and exhibitors were not. I managed to score a drink bottle by asking the helpdesk where I could find a cup to pour the water into.
The few times juice and water was poured into small plastic cups, they were guarded until the ‘official’ commencement of the meal time (morning tea, lunch, afternoon tea or dinner that is) – people were turned away, "15 minutes and then you can have one". Eventually the guards resorted to putting teatowels over all the cups so people wouldn’t notice that they weren’t out there.
Misc Fails
- [TechED UNI Student Day] Ms Megabyte was the wrong sort of ‘personality/celebrity’ to be presenting to uni students – I do realise she’s very accomplished in her own right, but she just didn’t suit the audience. I’m not sure many there knew who she was, and I’d hazard a guess that not many watch the TODAY show (heck, the majority of students I know aren’t even awake at that time!)
- Early bird pricing was apparently available up until registration for the opening party – yeah this is a minor point, but it is still silly that it was allowed to happen.
- The closing party was destined to fail before it officially started by requiring bags to be cloaked, that is no bags were allowed into the party, and from what I could see there was no prior notice about this. I’ll put that a bit more into context, ~3000 attendees (I think?), comprised of mostly geeks (and we all love our gadgets) going to a technical conference where having a laptop isn’t a bad idea, who were all given a large backpack when registering. Assuming not everybody still carried their bags on Thursday, I’ll say half, that is still ~1500 bags that needed to be checked in. It was an incredibly long, slow moving line.
Many laughed and left, not wanting to leave thousands of dollars of gadgets (laptops, cameras, etc) in the hands of strangers.
This isn’t to say I didn’t enjoy TechED, because I honestly had a blast, but I didn’t pay for it and I was there for other reasons. During the event and throughout the blogosphere I’ve noticed I’m not the only one to complain, so hopefully the right people will be reading all the comments they can to make TechED 09 sensational.
Before I make my comments about Silverlight 2 Beta 2, I’ve first had to get the darn thing working with Visual Studio 2008. Anytime I’d go to open a Silverlight project, I’d be greeted with "The project type is not supported by this installation".
Unfortunately, I was foolish enough to install the VS2008 SP1 beta/.NET 3.5 SP1 beta (largely thanks to the cool stuff mentioned at Remix) which apparently was the original cause of this problem. It wouldn’t be too bad if Blend had any IntelliSense, but unfortunately the only way to develop the C# behind the SL2 project is to use VS2008.
After several uninstall/reinstalls of everything I could find relating to VS2008 (and no more reinstalls of SP1 Beta), I stumbled across Michael Sync’s tips for Silverlight 2 Beta 1 Tools + VS2008. I uninstalled and reinstalled everything according to that post…but it turns out all I needed (no reinstalling required) was but one parameter while launching VS2008…
devenv.exe /resetskippkgs
Now I’m "enjoying" Silverlight 2 content again, but hopefully future versions of the SL2Chainer will fix this on install!
Update: Okay, so SL2B2 is coming out next week apparently, and it addresses at least some of the control issues! Maybe I’ll get some of my wants sooner rather than later.
No, this isn’t a leaked announcement of SL2B2, but things I want (need?) into Silverlight before v3. I’ve been playing with SL2B1 lately, and while I’d love to say it totally rocks and I’ll be using it everywhere from now on…but I just can’t bring myself to that level of fanboyism.
- Native WrapPanel, yes I know of the WrapPanel on CodeProject, but its not the same.
- Tile/TileBrush/Ability to tile images. I’m sure I’m not the only one who wants to use a tile background in parts of my app which can’t overlay HTML.
- “BitmapEffects“. While these have sort of been depreciated in WPF 3.5 in favour of PixelShaders, Silverlight doesn’t have the ability to do Inner/Outer Glow, Drop Shadows, etc.
- More controls – Think of this point as <em><em’ier><EM’iest!’>! I attempted some Silverlight 1 stuff, but it was a nightmare building anything “rich” because all controls had to be built by hand. Don’t get me wrong, SL2B1 has a lot more controls (and very common/useful ones at that), but there are still a fair few missing from WPF.
- Webcam support; Flash can do it, but I personally think the amount of media stuff that Silverlight can do would make it even more useful. Webcam support in Silverlight, along with additional controls like TreeView…you could replace whatever instant messenger you currently use with a completely web based/silverlight without losing any of the rich experience!
And on a more minor note (from me)…
- VS2008SP1 breaks Blend 2.5/Silverlight support? Argh!
- Perhaps less restrictive port ranges for Sockets, currently only 4502->4532 & 80 are supported. According to Robert Folkesson “the site of origin restriction will go away in future release“, maybe the port restrictions will too.
- can has Silverlight for WinMo now pleeeeease?
To me, Silverlight 1 was interesting in the aiblity to deliver WMV, but failed to really get my interesting. Silverlight 1.1/2 is a lot more powerful by bringing .NET into things as well as inbuilt controls (and yes, I know a host of other things), but it still doesn’t seem all there.
I can now see the obvious reason for why it was rebranded from the seemingly “good” codename of “WPF/E” (where the E stood for everywhere) – it’s not WPF, its sort of a subset, but not really.
Hopefully somebody is listening..
</Rant>