Using Drawables In TextViews

A common mistake I notice when reviewing Android development code is the use of more views than what is needed for the design. A good example of this is the use of three views (or more!) to create a very common pattern.

For instance, say the following was intended.

take_photo_buttonDevelopers have commonly implemented this using something that essentially has the following layout.

<RelativeLayout /* container */ >
   <ImageView /* image */  />
   <TextView /* text */ />

Android provides a much easier means to accomplish this. The same design above can be done using a single TextView.

    android:text="Take photo" />

Since API level 1, TextView has allowed setting Drawables either to the left of, to the right of, above, or below the text. These Drawables, also know as Compound Drawables, can be specified in XML or using methods. In addition to location of where the Drawable is placed, you can also indicate the padding to use. Using this functionality on simple designs allows you to place an image near text without the need of an ImageView. In many cases, you can greatly simplify the amount of views needed to create your Android designs.

My New Commuting Bicycle

After having my commuting bicycle stolen outside of a Denver restaurant in autumn of last year (bah!), I’ve been in need of a replacement.  But after the check for my home insurance claim arrived, I decided to hold off from buying a new one immediately since winter was around the corner.

Fast-forward to three days ago…

Motivated by the recent warm weather we’re getting before spring, the will to keep back in shape, and the sum of money saved from the home insurance check along with some recent birthday cash, I ventured out to find a new commuting bicycle.

I wasn’t sure what I wanted this time around, but I knew I didn’t want the same style of bike I had before.  Previously, I had bought a dual-sport.  Back then, I figured that since I loved MTBing, I wanted a bike with similar features but with better road efficiency.  While the dual-sport did just that, I decided not to go that direction again.

After spending parts of two days, going through the inventory at my local REI, Wheat Ridge Cyclery, and some random smaller bike shops, I found a bicycle that I really liked at the Westminster Bicycle Village: a 2011 Trek (1st) District in Matte Platinum.


There were several features/aspects of the Trek District that I loved:

  • It’s a single-speed bicycle, which means it doesn’t have the additional gears you normally find on bicycles.
  • It uses a belt-drive, so it replaces your standard oily, noisy bike chain with a totally silent, maintenance-free belt made of Kevlar.
  • The carbon fork, aluminum frame, single gear system, and aggressive road bike inspired geometry help to make the bike extremely light.
  • It has a really cool “urban”, yet vintage design/look.

Along with that, I was happy to discover Bicycle Village was having a clearance sale, which knocked the price down to $790 (vs. $1100-1200 MSRP).  So, after a quick test spin, I bought and brought home my new commuting bicycle. :-)

WarBall and the Muellers

For about 7 years now, my family/friends and I have had fun battling it out in a fantasy football league called WarBall.  To steal some text from the league’s manifesto, “WarBall is a highly competitive, private fantasy football league… If you have the intelligence, strategy, and decision-making to be a true general in the game of fantasy football, then WarBall is for you.”

“Highly competitive” is an understatement to me.  I’ve played in many other leagues, but none of them were as challenging to succeed in as WarBall.  I can honestly say I’ve had a lot of success in leagues outside of WarBall.  But in the 7 years of WarBall, not so much!  I finally did earn my first championship (last year!  yay!), but it wasn’t easy.  The runner-up and I continued a trend of having a different WarBall champion and runner-up every single season (in other words, no one has been the champion or runner-up twice).

Perhaps one could say that the competitiveness of WarBall is directly linked to the size of the prize pot (paid out to both the champion and the runner-up in a 70/30 split).  While that may be true, I’d like to attain that WarBall’s challengingly nature is attributed to the seasoned fantasy football gamers that play the game.

Why am I telling you this?  Well, considering my perception of WarBall’s competitiveness, it brings me joy to see my family members in the top ranks this season!  All 4 of the Muellers playing are part of the top 5 WarBall teams in our 14-team league this season.

This Mueller dominance of WarBall is very cool to see!  (At least to me!  :-p)   What’s even more neat is the fact that we are all roughly sitting around 7 – 4 (hats off to my sister with the slight lead!) heading into the last two games before the playoffs.  You can’t make this up people.

Go Muellers!

Update: After another round of games, which we won or tied, we all have the same winning percentage!

Update: I was the only one *not* to make the playoffs!  ūüėÄ  Congratulations goes out to my brother for winning WarBall this year!

A New Look

My site has a new look!  Since firing up the blog earlier this year, I’ve never taken the time to style my site and make it mine.  I’ve been using the same old, boring, out-of-the-box themes for WordPress.  But this past weekend, I decided to finally open up the hood and get my hands dirty.

I had three major goals in mind for the new design:

  • Simplicity
  • Flexibility
  • My own color scheme

The first point speaks for itself.  But I will say that a nice, simple design allows for better readability and that is important to me.  Regarding the second point, I wanted a flexible design similar to that of  No matter which screen resolution used when visiting the site, I wanted the content to render to a viewer’s screen size as best as possible.  (You can test this out by re-sizing your browser window, assuming you are able to.)  Lastly, I wanted my own color scheme.  I didn’t care for much of the palettes of colors I’d seen with much of the themes out there.  I just wanted a set that was straightforward and helped with my first point…keeping it simple.

I think I was able to achieve the goals I was going for and I like how the design ended up.  I might tweak some of the colors here or there down the road, but for the most part, I think the “new look” will remain for a while.

AdvancedDataGrid CSV Export Utility Class

Recently, I needed a way to export data from Adobe Flex’s AdvancedDataGrid control to CSV-formatted files for use in Microsoft Excel.  Since Flex did not provide a native method, I looked into some existing third-party libraries.  Those did not work out, so I ended up building my own AdvancedDataGrid CSV export utility class.

I first experimented with the excellent AlivePDF library.  I had used AlivePDF in the past to…well…create PDFs.  One of the things I remembered from using it was that there was CSV export functionality.  But after spending some time experimenting, I was disappointed to find it required quite a bit of overhead and would not be able to fully satisfy my needs.  Next, I turned my attention towards the AS3XLS library.  From what I could gather, the library seems like what you’d want if you were trying to read & write native Excel files, but it didn’t provide CSV support.

So, I started searching the intertubes for another option.  I found a great  post by Abdul Qabiz, demonstrating a home baked solution he had come up with.  The code he presented was quite dated (it was written for Flex 2, targeting the DataGrid control) and was missing some features I needed.  However, it was exactly what I needed as a starting point.  Learning from what he provided, I rolled my own solution that provided everything I was looking for.

Below is the AdvancedDataGrid CSV export utility class I came up with.  It compiles in Flex 3.5, Flex 3.6 and Flex 4.5, handles grouped column headers, can double-quote values, and is capable of saving the CSV data of any language to a file (through the use of UTF-16 encoding).  I am posting this simple class in case somebody else might find it useful.  If you do, please leave a comment.  Also, let me know if you find ways to improve it! 

Note: The final version of the code uses a tab as the default CSV delimiter.  This is due to a limitation in Excel when dealing with a comma-separated value file in UTF-16/Unicode encoding.  Despite the use of a tab character, the format of the file is still viewed as a “CSV”.  :-)

Download the code.

package net.onyxmueller.util
 import flash.utils.ByteArray;
 import mx.collections.ICollectionView;
 import mx.collections.IViewCursor;
 import mx.controls.AdvancedDataGrid;
 import mx.controls.advancedDataGridClasses.AdvancedDataGridColumn;
 import mx.controls.advancedDataGridClasses.AdvancedDataGridColumnGroup;
 public class CSVUtil
 private var _csvSeparator:String;
 private var _lineSeparator:String;
 private var _doubleQuoteValues:Boolean;
 private var _doubleQuoteRexExPattern:RegExp = /\"/g;
 private var _encoding:String;
 public function CSVUtil(csvSeparator:String = "\t", lineSeparator:String = "\n", doubleQuoteValues:Boolean = true)
 _csvSeparator = csvSeparator;
 _lineSeparator = lineSeparator;
 _doubleQuoteValues = doubleQuoteValues;
 public function formatAsCSVString(items:Array):String
 if (_doubleQuoteValues)
 // escape any existing double quotes then place double quotes around values
 for (var i:int = 0; i < items.length; i++)
 items[i] = items[i] ? items[i].replace(_doubleQuoteRexExPattern, "\"\"") : "";
 items[i] = "\"" + items[i] + "\"";
 return items.join(_csvSeparator) + _lineSeparator;
 public function advancedDataGridToCSVString(dg:AdvancedDataGrid):String
 var headerCSV:String = "";
 var headerItems:Array;
 var dataCSV:String = "";
 var dataItems:Array;
 var columns:Array = dg.groupedColumns ? dg.groupedColumns : dg.columns;
 var column:AdvancedDataGridColumn;
 var headerGenerated:Boolean = false;
 var cursor:IViewCursor = (dg.dataProvider as ICollectionView).createCursor();
 // loop through rows
 while (!cursor.afterLast)
 var obj:Object = null;
 obj = cursor.current;
 dataItems = new Array();
 headerItems = new Array();
 // loop through all columns for the row
 for each (column in columns)
 // if the column is not visible or the header text is not defined (e.g., a column used for a graphic),
 // do not include it in the CSV dump
 if (!column.visible || !column.headerText)
 // depending on whether the current column is a group or not, export the data differently
 if (column is AdvancedDataGridColumnGroup)
 for each (var subColumn:AdvancedDataGridColumn in (column as AdvancedDataGridColumnGroup).children)
 // if the sub-column is not visible or the header text is not defined (e.g., a column used for a graphic),
 // do not include it in the CSV dump
 if (!subColumn.visible || !subColumn.headerText)
 dataItems.push(obj ? subColumn.itemToLabel(obj) : "");
 if (!headerGenerated)
 headerItems.push(column.headerText + ": " + subColumn.headerText);
 dataItems.push( obj ? column.itemToLabel(obj) : "");
 if (!headerGenerated)
 // append a CSV generated line of our data
 dataCSV += formatAsCSVString(dataItems);
 // if our header CSV has not been generated yet, do so; this should only occur once
 if (!headerGenerated)
 headerCSV = formatAsCSVString(headerItems);
 headerGenerated = true;
 // move to our next item
 // set references to null:
 headerItems = null;
 dataItems = null;
 columns = null;
 column = null;
 cursor = null;
 // return combined string
 return headerCSV + dataCSV;
 public function saveAdvancedDataGridAsCSVFile(dg:AdvancedDataGrid, fileName:String, encoding:String = "utf-16"):void
 var csvString:String = advancedDataGridToCSVString(dg);
 var bytes:ByteArray = new ByteArray();
 // if using UTF-16, prefix file with BOM (little-endian)
 if (encoding == "utf-16")
 bytes.writeMultiByte(csvString, encoding);
 bytes.writeMultiByte(csvString, encoding);
 // prompt the user with a save location
 // note: FileReference requires a minimum flash player version of 10
 var fileReference:FileReference = new FileReference();, fileName);
 fileReference = null;

Improve Visual Studio 2010 Build Times

A co-worker pointed me to a great tip that improved my build times within Visual Studio 2010.  If you work with a large solution/project, this might help you.

Under Tools –> Options –> ‘Projects and Solutions’ grouping –> Build and Run –> Check ‘Only build startup projects and dependencies on Run’.

Only build startup projects and dependencies on Run

Check 'Only build startup projects and dependencies on Run'

Again, this is probably only useful if you have a larger solution like mine.  In my case, it brought my wait time down from minutes to under a minute.

Thanks Andy!

I have to give T-Mobile props

Note: This is a test post from the WordPress app for Android. Please excuse any mistakes caused by my “fat fingers.”

T-Mobile has been going from city to city, upgrading their network infrastructure to enable¬†HSPA+/4G speeds and become one of the largest (if not the largest) HSPA+/4G networks out there. ¬†I’ve been with T-Mobile for a long time (7+ years?) and it’s kind of cool that without having to pay a extra dime, my phone’s bandwidth in Denver went from fast to really fast without having to do anything. ¬†Check out the snapshot of my recent bandwidth test below:

2011.03.03 T-Mobile Denver speed test on Nexus One.

2011.03.03 T-Mobile Denver speed test on Nexus One.

Throw in better customer service (this is my opinion – I’ve had both AT&T and Nextel in the past) and the peace of mind that I’m getting a good deal on my cell phone plan, I can’t help but give T-Mobile props.

How to set the default email address for a Gmail contact

Have you ever composed a piece of mail in Gmail, started to type the name of a recipient in the To field, and been annoyed that an email address for a recipient is not the first option in the list that shows up for that person?  You might even always send email to that person using one particular address, but Gmail just never wants to make it the default or first option.


Have you composed mail to a (Gmail) contact group you created and found yourself having to replace unwanted/incorrect email addresses of recipients with the one you were intending?


Have you wanted to add contacts to your Gmail chat widget/box, clicked the ‘Add contact’, only to find Gmail providing non-Gmail addresses for suggested recipients in your top contacts?

Well, be inconvenienced no more! ¬†For each of your contacts that you would like to set the default email address for, edit their contact file, and set the¬†address you want to use as the default as the FIRST address in the contact’s file. ¬†(I hope my choice of¬†verbiage¬†makes sense.) ¬†Unfortunately, until Google provides something like a ‘Use as default’ checkbox, this is only way I’ve found to make a contact’s email address their default.

If you stumble across my post and this helps you, please leave a comment!  Thanks!