당신의 attrs PARAMS와 방법 및 생성자를 onDraw는 오버라이드 (override) 할 필요가
public LabelButton(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
if (attrs != null) {
// set your attrs
}
}
@Override
protected synchronized void onDraw(Canvas canvas) {
super.onDraw(canvas);
Paint textPaint = new Paint();
textPaint.setAntiAlias(true);
textPaint.setColor(textColor);
textPaint.setTextSize(textSize);
Rect bounds = new Rect();
textPaint.getTextBounds(totalText, 0, totalText.length(), bounds);
int x = getWidth()/2 - bounds.centerX();
int y = getHeight()/2 - bounds.centerY();
canvas.drawText(text, getLeft(), y, textPaint);// draw your text in coords
}
public synchronized void setText(String text) {
if (text != null) {
this.text = text;
} else {
this.text = "";
}
postInvalidate();
}