Side Project Progress

I’m finally making some headway on my customizable tables side project. I spent most of today working on the Javadoc stuff that I’m (still) stuck on with RTMg.mob, but eventually got fed up with it. Significantly, I found a relevant discussion of the problem on an Android Google Group and posted there. Hopefully that will turn up something useful to me in the next few days. Meanwhile, I’ll keep trying to figure out solutions to it myself and devote spare time to the customizable tables.

As for the side project, previously I had been doing some work to create and manage data structures to keep track of my custom UI. That turned out to be pretty difficult and kind of a nightmare to manage. I went around in circles trying to make my management scheme less horrible before I decided to try an orthogonal approach. If I could stick custom UI into a ListView, Android would manage all of the references to my UI elements for me. Additionally, it would give me an easily regulated vertical layout to push data into. This just happens to be an ideal way to format my tables.

I found a couple of approaches to create ListViews with custom Views as their contents. Of course, the problem with these approaches is that they again assume that I know what I want at compile time. When this is known, the xml resources for creating layouts are absolutely stellar at making layout creation easy. Unfortunately, by definition I can’t know this, nor can I have my program write xml for Android at run-time. My solution (so far) is to take the second example I found and go hack, hack, hack on it.

Specifically, I mimicked the row.xml layout by creating an hierarchy of View objects in the java code, changed all of the references to point to my objects instead of the xml, and then deleted the row.xml entirely. I was fortunate enough to have this not only compile, but actually just work the first time I ran it. For you non-computer scientists out there, that’s the programming equivalent of hitting the jackpot. It only happens every now and then to me (if I’m working on something that I don’t already know how to do) and it is always a really nice feeling.

The next step in moving this project forward is to come up with a clever, reasonable scheme for programmatically generating these types of layouts at runtime. I already know that I’ll be using an SQL database which I’m cheating using JSON shenanigans. The piece that is still missing is to parse that JSON into meaningful layout data. I also have to write the JSON based on user input specs, but these are two halves of the same problem. Essentially I need to create a JSON ‘code’ for describing UI layouts. Overall, I definitely must admit that this is the craziest thing I’ve ever tried to make Android do. As I was describing the lengths to which I’ve gone to create this weird little app, I realized that it is a lot of unconventional, weird code. This leads me to believe that the project will either end up crashing and burning completely, or becoming something cool and unique. Lets hope for the latter! 🙂

Edit: I thought for a minute I was being a dummy for using ListView instead of TableView, but it turns out that I may not be. ListView allows me to easily hook my UI up to my database, which is a lot more convenient than managing the queries myself. I had read that ListView did not allow for the items contained within to be clicked on, but this is definitely not the case (I just tested it). Furthermore, each row in a ListView is itself clickable and can be assigned an OnClickListener.