Sunday, 7 March 2010

Android User Interfaces

I am working on a colour processing program for android (more later once it works). A fundamental part of this is to create a custom view to use in the user interface - it will eventually display a colour wheel, but it is nowhere near that yet!
The problem was that I am creating a subClass of View, which draws something on the screen.
I then simply added it to my UI XML description and tried to use it.
I got an InflateException, which was a bit of a surprise.
It turns out that I made a mistake - I had overridden the simple View(Context) constructor, which would be fine if I was adding the view directly from a program, but to use it from XML you need to override another constructor, View(Context, AttributeSet).

Now I have done that it works. Sorry this makes no sense unless you are used to Android things, and if you are used to Android, it is probably obvious, but this will help me next time I forget! I found this out here.
Post a Comment