Hi everyone!

   I am trying to make a custom component, so for testing purposes I made a 
view that draws a white line. The code for the component follows:


public class CGrafico extends SurfaceView implements SurfaceHolder.Callback{


 public CGrafico(Context context) {

 super(context);

}

 public CGrafico(Context context, AttributeSet attrs) {

 super(context, attrs);

}

 public CGrafico(Context context, AttributeSet attrs, int defStyle) {

 super(context, attrs, defStyle);

}

@Override

protected void onDraw(Canvas canvas)

{

 super.onDraw(canvas);

  Paint estilo = new Paint();

 estilo.setARGB(255, 50, 55, 55);

  canvas.drawLine(0.0f, 0.0f, 10.0f, 10.0f, estilo);

}

@Override

public void surfaceChanged(SurfaceHolder holder, int format, int width, 
intheight) {

  }

@Override

public void surfaceCreated(SurfaceHolder holder) {

  }

@Override

public void surfaceDestroyed(SurfaceHolder holder) {

  }

}


I declared it on the xml layout just with the android:layout_width and the 
android:layout_height properties defined, both set to "fill_parent", and 
the main class of the application just calls setContentView with the XML 
layout as an argument.


My problem is that I have tested and the line the custom view was supposed 
to draw is not appearing, in fact, the onDraw function is not even being 
executed. I have tried to understand the example codes, and the developer 
page on Canvas and drawing, but I am too much of a newbie to see what I am 
doing wrong. Anyone have an idea on how to make it work?


Ricardo

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" 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-developers?hl=en

Reply via email to