
package com.book.minipangkakao;
import android.app.*;
import android.content.Intent;
import android.database.*;
import android.os.Bundle;
import android.util.*;
import android.view.*;
import android.view.View.*;
import android.widget.*;
public class TestInput extends Activity implements OnClickListener{
DBHandler dbHandler;
EditText edtName;
Cursor cursor = null;
String[] arr = null;
TextView tvi;
MainView mainview;
int s = 0;
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.testrank);
Button btn = (Button)findViewById(R.id.button1);
btn.setOnClickListener(this);
s = MainView.score;
s *=100;
edtName = (EditText)findViewById(R.id.editText1);
TextView tvi = (TextView)findViewById(R.id.textView3);
tvi.setText(" "+s);
}
public void onClick(View v){
dbHandler = DBHandler.open(this);
String sc = tvi.getText().toString();
try {
long re = dbHandler.insert(
edtName.getText().toString(),
sc); // 랭킹 등록 다이얼로그 버튼 누르면 - 인풋창 - 대신 스코어는 텍스트 두개줘서 하나 제목
// 다른 하나 점수 넘겨받기 - 그다음에 이 함수로 전달하면 될까?
if(re == 0){
Toast.makeText(this, "추가 실패", 2000).show();
}else{
Toast.makeText(this, "추가 성공", 2000).show();
cursor = dbHandler.selectAll();
arr = new String[cursor.getCount()];
int count = 0;
while(cursor.moveToNext()){
String code = cursor.getString(0);
String sang = cursor.getString(1);
String price = cursor.getString(2);
arr[count] = code + " " + sang + " " + price;
count++;
}
cursor.close();
}
} catch (Exception e) {
Log.i("disp", "err:" + e);
}
Intent intent2 = new Intent(TestInput.this, ListTest.class);
startActivity(intent2);
}
}
아마 빨간부분이 문제가 되는거같은데 로그를봐도 널포인터익셉션이라고만나오니 뭐가 문제인지를 모르겠네요..
참고로 에디트텍스트로 입력받은 값과, 텍스트뷰에 표시된 값을 DB로 전달하는게 목표입니다.