How to Dynamically Add Radio Buttons

Haven’t seen a tutorial for this that isn’t badly spelled and hard to grok, so I’ll try it.

First, include the radio group widget and and declare one. You’ll also need LayoutParams and RadioButton, so include those as well.

Inside your onCreate method, initialize the radio group. is referring to a radio group that’s declared in your XML file, so make sure you have that as well.

Back in SomeAndroidActivity, create a method to dynamically add buttons to the radio group.

Then call that method in onCreate.

Easy pie.

A different kind of college course


Bluetooth is not an easy thing to deal with, my instructor tells me. I didn’t believe him, and spent several fruitless weeks trying to get the Morse code Bluetooth chat app to work correctly.

The nature of application development, especially when it’s for a platform other than the one you write code on, is that you constantly stumble over bugs, weirdness and strange errors that aren’t your fault at all. It’s discouraging.

Even so, the course I’m currently taking in Android application development is the most interesting one I’ve had in my two-year Computer Systems Tech diploma program.

It was supposed to be about computer graphics. But the guy meant to teach it dropped out for some reason, and another teacher, here referred to as Robocop to protect his privacy, stepped in.

Robocop had about 3 weeks to come up with a curriculum, so the normal method of curriculum development wasn’t going to work. Instead he used the considerable leeway that the college allowed, to construct an experiment.

6 projects – students proposed and voted on ideas. (Time savings for the teacher – no assignment development).

Anyone can work in any project they want. Download the source from git, decide what you want to do, and do it. Push the changes, then sit back and wait for everyone else to bawl at you for breaking the build. Marking is done by peer reviews. You get a mark out of 10 based on whatever you’ve done this week, so anyone who makes a reasonable effort and documents it can have a perfect score. (Theoretical time savings for teacher – no assignment marking.)

The great thing is, you get as much out of it as you put in. You could do the bare minimum of testing code and maybe tossing out a toString or a small refactor once in a while, or you could rally a team, spend night and day working on, talking about, living in it, and create a commercial grade application from scratch, in three months, with adult supervision the whole time. (Now that I’m an adult I freaking loooove having adult supervision. Takes so much pressure off.)

I wouldn’t say it’s a 100% success – Robocop originally thought that we’d be able to come up with 6 commercially viable, clean, usable Android apps by the end of quarter. I think we’ll be lucky if even one of them technically does what we originally set out to do. Some people wasted a lot of time being confused, asking “What am I supposed to do? Where are the instructions?”

But as an experiment, it’s a home run. As education, it’s exactly what I wanted out of college. Preparation for working with people you don’t necessarily like, who might make brilliant decisions sometimes and really odd ones other times. The hot shame of responsibility for ruining weeks of other people’s work. The freedom to make whatever you want, if you can get the others to play along. I don’t know if the course will work long term for the college, since all the time Robocop saved before class started, he has to pay back trying to keep up with 6 open projects. I hope they keep it.

For me, personally, it’s not a success yet. Not until I can get the stupid Bluetooth connection to work right.



Android Thing for Saving Money on Springs and Avoiding Math

So, my race car is slow, and I cannot afford a new motor because I spend all my money on race cars. Another way to make it faster is to throw in some springs (and shocks) that are a little bit harder than the stock ones.

I flip through the parts catalogue and find some springs that ought to do the trick.Then I look at the price and have a stroke, because they cost like 10 bajillion dollars. Might as well get the new motor – might as well get a new car!

Hmm, maybe there’s a better way. I’m gonna go to the junk yard, where there are tons of perfectly good springs just sitting there in rotten old cars, where I can haul them away for scrap metal money. Dope! Only how do I know which ones are going to be just a little bit harder than my current springs, and also maybe an inch or so lower?

Hey, what. There’s an app for that. Here you go, linky. It is free but feel free to mail me money or whatever, just out of love and sympathy for the fact that I’m broke, and don’t even have a race car.


Put in some numbers that you can find or measure – the modulus of rigidity has to do with the quality of the steel in your spring – if you don’t know it and can’t find it, 14,947,500 is a reasonable number for Moog springs. Get out your calipers and measure the diameter of the wire. Get out your ruler and measure the diameter of the spring. Count up the number of active coils, you don’t even need a tool for that (just the one in your…head). Whang all the numbers in, and the calculator will tell you the spring return rate. Compare those numbers against the ones for your buddy’s cool blue springs, and find out if the 3 coils in a Ford pickup are equivalent to the 6 coils in your Corolla. And if they are, get those springs, get low, and hold on to your money.

If you want to get super scientific, you can calculate any of the five values, calculating your modulos of rigidity for various springs, averaging them up and so on. I leave it to the nerds to figure that out. I may later add the ability to save spring specs for easier comparing, but this is an MVP. That’s Minimum Viable Product, cause holy cow, I am so new at this game.

Things I learned

First of all, I found an easier way of wiring up an OnClick listener. It turns out you can make one OnClick listener for several buttons that do similar things, rather than creating a new OnClick object for each one. Not that it was relevant in this project anyway, since there’s only the one button.

Another good lesson was How To Avoid Doing Math. I got the formula from a website for shed engineers, as directed by DiscoQuinn (my first customer, lol). I then had a couple of helpful friends (Serge)(Matt) do the basic algebra to convert the formula to solve for the other 4 variables. Then I fed the calculator on the shed engineer’s page 5’s for every value, noted the spring return rate, and used those numbers to write JUnit tests for all the variables. AssertTrue(k == 2.605) and assertTrue(n == 5) for everything else, like so:

I’m really pleased about that.

Overall, I’m happy cause I learned a little bit and made something kind of useful. My code this time around is much more beautiful than what I did in the CFM calculator. One con is that I got so wrapped up in coding this, and enjoyed it so thoroughly, that I let my school work slide a bit. Hopefully by posting this, feature-poor as it is, I can put it to bed and focus on my C homework!

Justifying a trip to Australia via Cochlear Implants and programming


Being Deaf


I use a cochlear implant to help me hear. The thing is amazing, and it’s changed my life. Like, it’s the difference between being a shut-in with no life and being happy, well adjusted contributing citizen. But I always like to understand the devices I use in my life, tweaking and modifying them to suit me. I’d like a phone application to control it, or use it to receive phone calls, or whatever. Make the implant itself the size of the loonie, like the magnet part currently is, and control it only remotely. In this way it could be more seamless and waterproof.





I’m almost done my diploma in Computer Systems Technology. It’s a practical, hands-on course where you get tons of programming experience, like probably more than the average software engineering graduate gets. Last year we had a pretty amazing teacher for Java – a rather hard headed individual who was tough to get along with, however, he demanded more out of us than most teachers do, and got what he asked for. I think everyone who passed the course came away with an actual understanding of Java.

This year he’s teaching us Android programming. You can imagine how stoked I am. After this I’ll be able to build the interface for exactly the program that I want to control my CI.




Moving to Australia


The company that makes my CI is located in Brisbane, Australia. I’m going to be moving there in about 6 months. I’ll  have a diploma in computer programming, 6 years of being a CI user, and the ability, unlike many deaf people, to communicate clearly in English my needs and ideas for improving the equipment, and I’ll be in the city looking for a job.

Am I not the exact person that Cochlear is looking for? I think so. My mission now is to let them know.


For  CI company that makes my CI, which is based in Australia, in Brisbane where I’m moving to anyway, to hire me to make remote controls applications for their equipment. Everything kind of… works.

So, I’ll do the online application and all that. But this is going out to the internet, in hopes of finding the engineer, now working at Cochlear in Brisbane, who might be able to make room in his budget for one more engineer who has something special to offer.



Screw you world, I finished a project



It is a moderately useful Android app that you are welcome to download from here. The app does some very simple math – given the size of an engine, the maximum RPM of the engine, and the volumetric efficiency of the engine, it tells you what CFM value you need when shopping for a carburetor. CFM stands for Cubic Feet per Minute.

I think I mentioned something about being frustrated with the developer tools last week, can’t remember. Anyway, it’s fine now.


App is  here, source code is here.


Skipping School

I stayed home from school today. I thought all my classes would be cancelled because of a teacher’s strike, but it turns out that my teachers have no objection to crossing picket lines, and classes went on as usual. However, by the time I found out, I was already lost in a coding haze.

When you have a good flow going, it is very difficult to stop. As per a couple of facebook posts that some friends of mine may have seen, I am trying to start developing Android apps. This requires installing an IDE (Integrated Development Environment) and a plugin for that program, to emulate an Android phone on my laptop.

This was not an easy process. At first the emulator worked fine, and I was able to run a simple tutorial application, but then everything seemed to stop working, and I couldn’t figure out whether the problem was my code, or the tools I downloaded. I’m still not sure, to be honest. But after several days of constant googling about it, I got the emulator to work. Several hours after that, I got my code to work.

Some people are familiar with the “flow” state, where you spend hours working on something and get totally lost in it. At best, days pass unnoticed, and you end up with some minor success. I hope some of you can share my feeling of relief when my code finally worked. For the others, I hope I can encourage you to spend time doing the things you love, and get lost in them.

Sometimes you have to shut up the voices that tell you the things you’re doing are a waste of time, and that you should do homework, or chores or exercise or whatever. Ignore those voices. A good flow is never a waste of time, it is a reward on its own.

If you’re curious,  the app in question is a simple calculator for determining what size of carburetor to mount on an engine, given the size of the engine and the maximum RPM of the motor. It’s pretty crude, but you can have my code if you want. Leave your name and email.