Bump...anyone?
On Jun 15, 7:42 pm, Dave Smith <[email protected]> wrote:
> Hi all -
>
> I'm trying to get a custom view example running out of the
> "Professional Android Application Development" book (the
> CompassView). I have checked over my code numerous times, and still
> the same problem occurs...whenever I run the application I only see a
> black screen and the view never pops up.
>
> I have stepped through the debugger a few times and I have two
> theories:
> 1. I have a problem with onMeasure()...my code is currently calling
> setMeasuredDimension with 0,0
> 2. The view might be invisible...I read back the value of
> CompassView.isShown() and it read false
>
> Here is the measure code that is being used:
> @Override
> protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec)
> {
> // The compass is a circle that fills as much screen as
> possible.
> // Set the measured dimensions to the shortest screen
> boundary.
> int measuredWidth = measure(widthMeasureSpec);
> int measuredHeight = measure(heightMeasureSpec);
>
> int d = Math.min(measuredWidth, measuredHeight);
>
> //setMeasuredDimension must be called by onMeasure
> setMeasuredDimension(d, d);
> }
>
> private int measure(int measureSpec){
> int result = 0;
>
> //Decode the spec value
> int specMode = MeasureSpec.getMode(measureSpec);
> int specSize = MeasureSpec.getSize(specMode);
>
> if(specMode == MeasureSpec.UNSPECIFIED){
> //Return a default value
> result = 200;
> } else {
> //Return full bounds since we are filling available
> space
> result = specSize;
> }
>
> measure() is returning MeasureSpec.EXACTLY for mode and 0 for size
> from both width and height. How is that possible? I can attach more
> code if necessary, because my other problem is that onDraw() never
> gets called...but I thought that might have something to do with
> having no size.
>
> If it matters, I ran this under Android 1.1 and 1.5 to be sure I
> didn't miss something in a version update.
>
> Thanks in advance!
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---