How to draw a rectangle

Put your problem here if it does not fit any of the other categories.

How to draw a rectangle

Postby nithin.warier » Fri Mar 07, 2008 2:49 pm

I tried to draw a rectangle using this code, but not working, showing Nullpointer exception

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. public void onCreate(Bundle icicle) {
  2.  
  3.         super.onCreate(icicle);
  4.  
  5.         paint = new Paint();
  6.  
  7.         paint.setStyle(Style.FILL);
  8.  
  9.         paint.setARGB(255, 80, 150, 30);
  10.  
  11.         rect = new RectF(0,4,4,4);
  12.  
  13.         canvas.drawRect(rect, paint);
  14.  
  15.      }
Parsed in 0.032 seconds, using GeSHi 1.0.8.4


please help......

Thanks
Nithin
nithin.warier
Experienced Developer
Experienced Developer
 
Posts: 87
Joined: Thu Feb 28, 2008 12:05 pm
Location: Malappuram Kerala India

Top

Postby plusminus » Fri Mar 07, 2008 3:07 pm

Hello Nithin,

did you initialize "[font=Lucida Console]canvas[/font]".
Debugging helps!

Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Postby nithin.warier » Fri Mar 07, 2008 3:13 pm

hi plusminus,
javascriptemoticon(':D')
Thanks
nithin.warier
Experienced Developer
Experienced Developer
 
Posts: 87
Joined: Thu Feb 28, 2008 12:05 pm
Location: Malappuram Kerala India

Postby plusminus » Fri Mar 07, 2008 4:43 pm

:D
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 20 guests