public class session extends Activity
{
TextView tvDate;
TextView[] tv_date;// = new TextView[30];
Button[] btn_signature;// = new Button[30];
Button[] btn_note;// = new Button[30];
// GPS 변수
LocationManager mLocMan;
String mProvider;
String formattedLoc = "0,0"; // 조사한 위치를 저장하는 변수
// 이미지 업로드 변수
private FileInputStream mFileInputStream = null;
private URL connectUrl = null;
String lineEnd = "\r\n";
String twoHyphens = "--";
String boundary = "*****";
// 위젯 초기화
// Error here
/*
public void initWidget()
{
tv_date[0] = (TextView)findViewById(R.id.tv_date1);
//tv_date[1] = (TextView)findViewById(R.id.tv_date2);
//tv_date[2] = (TextView)findViewById(R.id.tv_date3);
// + 4 형태로 연산이 가능하다면 추 후 for문으로 교체
btn_signature[0] = (Button)findViewById(R.id.btn_signature1);
//btn_signature[1] = (Button)findViewById(R.id.btn_signature1 + 4);
//btn_signature[2] = (Button)findViewById(R.id.btn_signature3);
btn_note[0] = (Button)findViewById(R.id.btn_note1);
//btn_note[1] = (Button)findViewById(R.id.btn_note2);
//btn_note[2] = (Button)findViewById(R.id.btn_note3);
}
*/
@Override
public void onCreate(Bundle savedInstanceState)
{
//tvDate = (TextView)findViewById(R.id.tv_date1);
//tv_date = new TextView[30];
//tv_date[0] = (TextView)findViewById(R.id.tv_date1);
//tv_date[1] = (TextView)findViewById(R.id.tv_date1);
//tv_date[2] = (TextView)findViewById(R.id.tv_date1);
// + 4 형태로 연산이 가능하다면 추 후 for문으로 교체
//btn_signature[0] = (Button)findViewById(R.id.btn_signature1);
//btn_signature[1] = (Button)findViewById(R.id.btn_signature1 + 4);
//btn_signature[2] = (Button)findViewById(R.id.btn_signature3);
//btn_note[0] = (Button)findViewById(R.id.btn_note1);
//btn_note[1] = (Button)findViewById(R.id.btn_note2);
//btn_note[2] = (Button)findViewById(R.id.btn_note3);
//initWidget();
final SessionObject[] sessionList = new SessionObject[30];
for(int i = 0; i < 3; i++)
sessionList[i] = new SessionObject(i+1);
super.onCreate(savedInstanceState);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.session_main);
// 이 부분도 그림파일 말고 다른 엔트리를 검사해도 가능할듯
// 처음 메인에서 그림파일과 노트를 검사하고 버튼 텍스트를 바꾸는 부분
// 버튼이 눌려지기 전부터 버튼의 텍스트를 바꿔야 하므로 onCreate 영역에서...
for(int i = 0; i < 3; i++)
{
File imgFilesDir = getFilesDir();
String imgFileName = "signature" + sessionList[i].getSessionNum() + ".png";
File imgFile = new File(imgFilesDir, imgFileName);
// signature#이 존재하면 버튼을 변경(서버에서 받은 파일을 검사)
if(imgFile.exists())
btn_signature[i].setText("Signature " + sessionList[i].getSessionNum());
// note#이 존재하면 버튼을 변경
if(sessionList[i].getNote() != "")
btn_note[i].setText("Note " + sessionList[i].getSessionNum());
}
Button.OnClickListener mClickListener = new View.OnClickListener()
{
public void onClick(View v)
{
// + 4 형태의 연산이 가능하다면 case문이 필요 없을지도...
switch(v.getId())
{
case R.id.btn_signature1:
// R: 깊은 복사를 처리해줘야 하나?
// String과 primitive type에 대해서는 필요가 없음...
// processSession에서 openSessionOutputDlg로 분기된다면,
// 이 할당문은 의미가 없음
sessionList[0] = processSession(sessionList[0]);
break;
case R.id.btn_signature2:
//sessionList[1] = processSession(sessionList[1]);
break;
case R.id.btn_signature3:
//sessionList[2] = processSession(sessionList[2]);
break;
case R.id.btn_note1:
//sessionList[0] = processNote(sessionList[0]);
break;
case R.id.btn_note2:
//sessionList[1] = processNote(sessionList[1]);
break;
case R.id.btn_note3:
//sessionList[2] = processNote(sessionList[2]);
break;
} // End Of switch statement
} // End Of onClick()
}; // End Of mClickListener
findViewById(R.id.btn_signature1).setOnClickListener(mClickListener);
findViewById(R.id.btn_signature2).setOnClickListener(mClickListener);
findViewById(R.id.btn_signature3).setOnClickListener(mClickListener);
} // End Of onCreate()
}
//코드하이라이터가 세부분으로 나뉜 것은 알 수 없는 오류입니다.
//전부 이어져있다고 생각해주세요.
에러가 나는 시점이 컴파일 타임이 아니고 처음 프로그램을 실행시키자마자
session_main(가장 처음 불리는 레이아웃)을 띄우지 못하고 죽어버립니다.
session 클래스의 멤버함수도 많이 있고 다른 클래스도 있으나
에러타임을 봤을 경우 별로 상관이 없다고 생각돼서 일단 이 부분만 올려봤습니다.
쓸데없는 주석이 좀 많은데요.
중요하게 봐야될 부분은 멤버변수로 선언해준
위젯 배열들... 중에서
TextView tvDate;
TextView[] tv_date;// = new TextView[30];
위 선언문과 (new TextView[30]을 멤버변수 선언시에 넣으나, onCreate에서 넣으나 동일하게 에러가 발생했습니다.)
뒤따르는 선언문인데요.
tvDate = (TextView)findViewById(R.id.tv_date1);
tv_date = new TextView[30];
tv_date[0] = (TextView)findViewById(R.id.tv_date1);
이 코드들을 넣으면 에러가 나고
주석처리를 하면 에러가 나지 않습니다.
tvDate는 혹시 위젯을 배열로 선언했을 때 거기서 문제가 생기지 않나 해서
단일 변수를 만들어 본 것인데 이것도 마찬가지로 에러가 발생했습니다.
논리적으로 어디가 틀렸는지 전혀 알 수가 없는데,
어떻게 해결해야될 지 모르겠습니다.
혹시나해서 이것도 생성자로 초기화해야하나 하고
TextView tv_date = new TextView((TextView)findViewById(R.id.tv_date1);
이런식으로도 해봤는데 생성자가 없다고 하더군요.
여기서 문제될게 없다면 다른 부분도 올려보도록 하겠습니다.
그리고 또 Activity를 확장하는 클래스의 특징이 궁금합니다.
제가 처음에 시도했던 부분은
session()이라는 생성자를 만들고 거기서 초기화를 하려고 했었는데
session(){}이런 형태의 아무 일도 하지 않는 생성자를 만들어도 에러가 나더군요,
Activity를 상속하는 클래스는 이게 불가능한 듯 싶었습니다.
그래서 새로 initWidget()이라는 함수를 정의했는데,
여기서 public void 형태로 선언하면
onCreate()에서 호출했을 때 에러가 나서
그래 인스턴스가 없는 클래스니깐
static으로 선언해야겠다
하고 static까지 선언을 했는데
변수도 전부다 static이어야 한다
해서 static으로 지정했는데
이번엔 findViewById부분에서 에러가 나더군요.
스태틱변수는 스태틱이 아닌 레퍼런스를 참고할 수 없다는 에러였었나...
처음에는 단순히 static성격의 클래스라고 생각했는데(그래서 생성자가 없나...)
static 선언문도 없고
함수를 호출하는데도 이상하게 에러가 나버리니까
뭔가 다른 특징이 있는건 아닐까 싶은데
그걸 잘 모르겠네요...
그걸 알아야 이 문제를 해결할 수 있을것 같기도 하구요.
긴 글 읽어주셔서 감사합니다.
급한데 빨리 해결되었으면 좋겠네요... ㅠ




logcat에 나타나는 오류를 좀 보여주세요