I will start by saying this, while I have some Java training, is my first foray into development for Android.
What I have done is created a custom ImageButton
called MapCell
that is basically an ImageButton
that holds a few extra pieces of information, and it compiles fine.
My problem comes when I want to procedurally create a MapCell
in the relevant Activity
and add it to my TableLayout
which is defined in the xml and has the id 'mapTable'. The relevant bit looks like this:
Random randy = new Random();
MapCell n = new MapCell(randy.nextInt(4), this); //the random number is part of my extra info
findViewById(R.id.mapTable).addView((View)n, 20, 20); //add cell to display
I get one error out of that:
The method addView(View, int, int) is undefined for the type View
Which to me sounds like utter nonsense. I put that View
cast in there as desperation after I got this same error with n
sitting by itself and nothing changed (Obviously my MapCell
is already a View
since it extends ImageButton
).
I hope a new pair of eyes can tell me what this is about, since I've checked for similar problems and I didn't find any quite like this. Let me now if you need to see more code.