0
String sel="SELECT "+stdb.sid+"," +stdb.amt+", "+stdb.details+" FROM "+stdb.tname;
Cursor c=dobj.rawQuery(sel, null);
while(c.moveToNext()){
int id=c.getInt(c.getColumnIndex(stdb.sid));
int amt=c.getInt(c.getColumnIndex(stdb.amt));
String printdetail=c.getString(c.getColumnIndex(stdb.details));
TextView tv1=(TextView)findViewById(R.id.textView1);
Log.e("gg",""+amt); //the value of amt comes in logcat
tv1.setText(""+amt);//this gives nullpointer exception
在这里,我想从一个EditText,我能够看到logcat的价值,但值当我尝试打印相同的用的setText(TextView的)我得到一个NullPointerExceptionsqlite的空指针异常
如果amt不为null,则tv1必须为null。 – JesusFreke 2012-08-07 20:26:23
@JesusFreke先生我得到了我在logcat中的edittext中输入的值 – dreamer1989 2012-08-07 20:28:00
正确的,所以当你尝试解除引用'tv1'时,你会得到'NullPointerException'。 'amt'的价值不是问题。 – Argyle 2012-08-07 20:29:31