Android Layout findViewById Returns Null

Every once in a while you run across a coding issue that has occurred in the past but you can’t remember the resolution. Tonight is one of those times and the issue was an Android Layout one.

I had a layout xml file with the following id on a TextView:

id=”@+id/foo”

In the OnCreate() method I set the content view:

setContentView(R.layout.my_main);

And then went to get the TextView as such:

TextView foo = (TextView) this.findViewById(R.id.foo);

The problem is, foo is always null.

The issue here is that you must use the correct schema for the id node, which I’m guessing is compiling correctly due to some past version compatibility “feature” in the Android code. Simply making the change to use android:id as shown below, made the null an issue of my past (again) and now I can move on to using the TextView any way I like.

android:id=”@+id/foo”

The Funny Thing About Mobile Ads, And Our Future

Just a few short years ago, mobile ads were considered the scourge of mobile apps. Reviews of any app that would try their luck with this monetization method often found that they were “1 starred to death”. Has this changed recently? In the Android space it appears that the numbers have grown to the point that large developers are using the Ad model as their only means for income.

Tonight I tried moving one of my Apps to the AdMob model, and within hours calculated that if the trend continued at it’s pace (and really it should have something better than a linear increase over time as users install the app and come back to it now and then) the app would do better than the last 12 months.

Just over 2 years ago I felt compelled to move to the Android platform, as I knew that our computers would move to handheld size sooner, rather than later. We are about to enter a time where the little device we carry is really not just the communicator, but our complete digital experience. The device we carry will be the way we access many of the things that make us who we are: our past, our medical records, our family, our money, our shared thoughts.

So the funny thing about mobile ads is this:  We accept their place in all of this. People understand that this is the way it works, ads live with our lives.  In this new digital age we bring with us the past, a past drenched with Folgers commercials and diaper ads. The funny thing about mobile is given free, we will take it – gladly giving our thoughts paid in clicks as payment.

ToMarket Grocery Shopping List

OK, lets get this one out of the way early. I have a little shopping app on the Google Android platform. The idea started some time before the initial Android release and it’s first phone, the G1, when my wife was complaining about her Palm device being a dog. I told her about the impending Google mobile OS, and she said I should write a replacement for an App she liked, called HandyShopper. Without looking at the app, I interviewed her and wrote a set of requirements out and got to work. I had a free app in the market shortly after launch, and a paid one on the day they allowed paid apps. A couple of years have passed, and there is still a strong user base that enjoys the app and participates in the community over on http://ToMarketWeb.com. OK, enough of the self plugging, but if you find yourself with an Android device, check out ToMarket.