问题描述
- 为什么点击文本查询单词就闪退
- 就是我把别人低版本的词典源代码原装复制过来结果一查单词就闪退,告诉我访问不了数据库。但是我把数据库已经复制过来了呀!下面是报错的地方
05-23 10:14:13.195: E/AndroidRuntime(5635): java.lang.NullPointerException
05-23 10:14:13.195: E/AndroidRuntime(5635): at com.example.nnnnn.Main.afterTextChanged(Main.java:91)
05-23 10:14:13.195: E/AndroidRuntime(5635): at android.widget.TextView.sendAfterTextChanged(TextView.java:7095)
05-23 10:14:13.195: E/AndroidRuntime(5635): at android.widget.TextView$ChangeWatcher.afterTextChanged(TextView.java:8743)
05-23 10:14:13.195: E/AndroidRuntime(5635): at android.text.SpannableStringBuilder.sendAfterTextChanged(SpannableStringBuilder.java:970)
05-23 10:14:13.195: E/AndroidRuntime(5635): at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:497)
05-23 10:14:13.195: E/AndroidRuntime(5635): at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:435)
05-23 10:14:13.195: E/AndroidRuntime(5635): at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:30)
05-23 10:14:13.195: E/AndroidRuntime(5635): at android.view.inputmethod.BaseInputConnection.replaceText(BaseInputConnection.java:672)
05-23 10:14:13.195: E/AndroidRuntime(5635): at android.view.inputmethod.BaseInputConnection.commitText(BaseInputConnection.java:196)
05-23 10:14:13.195: E/AndroidRuntime(5635): at com.android.internal.widget.EditableInputConnection.commitText(EditableInputConnection.java:183)
05-23 10:14:13.195: E/AndroidRuntime(5635): at com.android.internal.view.IInputConnectionWrapper.executeMessage(IInputConnectionWrapper.java:279)
05-23 10:14:13.195: E/AndroidRuntime(5635): at com.android.internal.view.IInputConnectionWrapper$MyHandler.handleMessage(IInputConnectionWrapper.java:77)
05-23 10:14:13.195: E/AndroidRuntime(5635): at android.os.Handler.dispatchMessage(Handler.java:99)
05-23 10:14:13.195: E/AndroidRuntime(5635): at android.app.ActivityThread.main(ActivityThread.java:4928)
05-23 10:14:13.195: E/AndroidRuntime(5635): at java.lang.reflect.Method.invokeNative(Native Method)
05-23 10:14:13.195: E/AndroidRuntime(5635): at java.lang.reflect.Method.invoke(Method.java:511)
05-23 10:14:13.195: E/AndroidRuntime(5635): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791)
05-23 10:14:13.195: E/AndroidRuntime(5635): at dalvik.system.NativeStart.main(Native Method)
点击之后报了这里错误:
public void afterTextChanged(Editable s) {
//查询错了
Cursor cursor=database.rawQuery("""" +
select english as _id from t_words where english like ?""
new String[]
{ s.toString() + ""%"" });
DictionaryAdapter dictionaryAdapter = new DictionaryAdapter(this
cursor true);
actvWord.setAdapter(dictionaryAdapter);}
有没有哪位大牛 教下我!谢谢
解决方案
数据库连接串有没有问题?