मैंने एक वर्ग को उस तरह परिभाषित किया that
public class TestMyFrameLayout extends FrameLayout{
Paint mPaint;
public TestMyFrameLayout(Context context, AttributeSet attrs) {
super(context, attrs);
}
public TestMyFrameLayout(Context context) {
super(context);
mPaint = new Paint();
mPaint.setColor(Color.GREEN);
}
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
canvas.drawCircle(50f, 50f, 30, mPaint);
}
}
और इसे बुलाया:
TestMyFrameLayout myFrameLayout = new TestMyFrameLayout(this);
LayoutParams myFrameLayoutParams = new LayoutParams(300,300);
myFrameLayout.setLayoutParams(myFrameLayoutParams);
setContentView(myFrameLayout);
लेकिन वास्तव में TestMyFrameLayout.onDraw (कैनवास कैनवास) फ़ंक्शन को कॉल नहीं किया जा रहा है, क्यों?
@OverrideOnDraw से पहले भी जोड़ें : यह ग्रहण में टाइपो के लिए जाँच करेगा।