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);
try {
long re = dbHandler.insert(
edtName.getText().toString(),
tvi.getText().toString());
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);
}
}
에디트텍스트를 통해 얻은 값과 변수 s값을 DB에 전달하고싶은데 에러는 안나는데 옮겨지지가 않습니다.
아무래도 빨간색으로 되어있는 insert문을 고쳐야할거같은데 방법을 모르겠네요...
String price = cursor.getString(2); 인트형으로 바꿔보고 컬럼값 인트, 텍스트 다 해봤는데 안되네요...
어제 아침부터 하루종일 이것만 잡고있네요 ㅠㅠ