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