안녕하세요!! 공지사항 확인했습니다.
아래와 같이 canvas를 이용한 표 그리기에서 xml부분에 Week_View1클래스를 참조하는 부분이 추가되면 에뮬실행에서 Sorry가 뜹니다. Week_View1클래스 참조부분에 대한 조언 부탁 드립니다.
package com.WeekView;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
public class Week_List1 extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
String cc = null;
Log.e(cc, "setContentView");
}
}
----------------------------------------------------------------------
package com.WeekView;
import android.app.Activity;
import android.content.Context;
import android.graphics.*;
import android.util.AttributeSet;
import android.view.*;
public class Week_View1 extends View{
private Rect wRect;
private Paint wPaint;
public Week_View1(Context context, AttributeSet attrs) {
super(context, attrs);
wRect.top = 30;
wRect.bottom = getHeight();
wRect.left = 0;
wRect.right = getWidth();
}
@Override
protected void onDraw(Canvas canvas) {
int cellWidth = getWidth()/8;
int cellWidthW = getWidth()/18;
wRect.top = 30;
wRect.bottom = getHeight();
wRect.left = 0;
wRect.right = getWidth();
wPaint.setStyle(Paint.Style.STROKE);
wPaint.setColor(0xffffffff);
int x=0, y=0;
//세로줄 출력
for(int i =0; i<=8; i++){
x += cellWidth;
canvas.drawLine(x, wRect.top,x, wRect.bottom, wPaint);
}
//가로줄 출력
for(int i =0; i<=17; i++){
x += cellWidthW;
canvas.drawLine(wRect.left, y, wRect.right, y, wPaint);
}
super.onDraw(canvas);
}
}
-------------------------------------------------------xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout android:id="@+id/RelativeLayout01"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<com.WeekView.Week_View1
android:id="@+id/wView01"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
</RelativeLayout>