我從Activity類這樣的對象:傳遞活動對象以非活性類的android
CustomPaint customCanvasPaint=(CustomPaint) dialog.findViewById(R.id.customCanvasPaint);
如何將這個對象傳遞給類是這樣的:
public class CustomPaint extends CanvasView {
public CustomPaint(Context context) {
super(context);
initialize(context);
}
public CustomPaint(Context context, AttributeSet attrs) {
super(context, attrs);
initialize(context);
}
public void initialize(Context context){
LayoutInflater inflater=(LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view=inflater.inflate(R.layout.custom_paint,null);
CanvasView canvasView = (CanvasView) view.findViewById(R.id.customCanvasView);
canvasView.setPaintStrokeColor(Color.RED);
canvasView.setPaintStrokeWidth(12f);
}
}
我要定製初始化方法中的對象,但繪畫顏色和繪製寬度不會更改。 如何做到這一點? 謝謝。
對象是不是CanvasView – handerianous