每当我将charsequence转换为字符串时,我的应用程序会显示强制退出消息。这是代码
public void onTextChanged (CharSequence s, int start, int before, int count) {
String query = td.searchRecord(s.toString());
Toast.makeText(getApplicationContext(),query, Toast.LENGTH_SHORT).show();
}
这是logcat。
06-30 16:08:46.004: INFO/ActivityManager(40): Starting activity: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.menu.san/.OptionsmenuActivity }
06-30 16:08:46.394: INFO/ActivityManager(40): Start proc com.menu.san for activity com.menu.san/.OptionsmenuActivity: pid=309 uid=10041 gids={}
06-30 16:08:48.024: INFO/ActivityManager(40): Displayed activity com.menu.san/.OptionsmenuActivity: 1719 ms (total 1719 ms)
06-30 16:08:49.485: WARN/KeyCharacterMap(309): No keyboard for id 0
06-30 16:08:49.485: WARN/KeyCharacterMap(309): Using default keymap: /system/usr/keychars/qwerty.kcm.bin
06-30 16:08:49.584: DEBUG/AndroidRuntime(309): Shutting down VM
06-30 16:08:49.584: WARN/dalvikvm(309): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
06-30 16:08:49.616: ERROR/AndroidRuntime(309): FATAL EXCEPTION: main
06-30 16:08:49.616: ERROR/AndroidRuntime(309): android.database.sqlite.SQLiteException: bind or column index out of range: handle 0x23bd30
06-30 16:08:49.616: ERROR/AndroidRuntime(309): at android.database.sqlite.SQLiteProgram.native_bind_string(Native Method)
06-30 16:08:49.616: ERROR/AndroidRuntime(309): at android.database.sqlite.SQLiteProgram.bindString(SQLiteProgram.java:241)
06-30 16:08:49.616: ERROR/AndroidRuntime(309): at android.database.sqlite.SQLiteQuery.bindString(SQLiteQuery.java:182)
06-30 16:08:49.616: ERROR/AndroidRuntime(309): at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:48)
06-30 16:08:49.616: ERROR/AndroidRuntime(309): at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1345)
06-30 16:08:49.616: ERROR/AndroidRuntime(309): at android.database.sqlite.SQLiteDatabase.queryWithFactory(SQLiteDatabase.java:1229)
06-30 16:08:49.616: ERROR/AndroidRuntime(309): at android.database.sqlite.SQLiteDatabase.query(SQLiteDatabase.java:1184)
06-30 16:08:49.616: ERROR/AndroidRuntime(309): at android.database.sqlite.SQLiteDatabase.query(SQLiteDatabase.java:1301)
06-30 16:08:49.616: ERROR/AndroidRuntime(309): at com.menu.san.DbHelper.searchRecord(DbHelper.java:67)
06-30 16:08:49.616: ERROR/AndroidRuntime(309): at com.menu.san.OptionsmenuActivity$2.onTextChanged(OptionsmenuActivity.java:65)
06-30 16:08:49.616: ERROR/AndroidRuntime(309): at android.widget.TextView.sendOnTextChanged(TextView.java:6131)
06-30 16:08:49.616: ERROR/AndroidRuntime(309): at android.widget.TextView.handleTextChanged(TextView.java:6172)
06-30 16:08:49.616: ERROR/AndroidRuntime(309): at android.widget.TextView$ChangeWatcher.onTextChanged(TextView.java:6316)
06-30 16:08:49.616: ERROR/AndroidRuntime(309): at android.text.SpannableStringBuilder.sendTextChange(SpannableStringBuilder.java:889)
06-30 16:08:49.616: ERROR/AndroidRuntime(309): at android.text.SpannableStringBuilder.change(SpannableStringBuilder.java:352)
06-30 16:08:49.616: ERROR/AndroidRuntime(309): at android.text.SpannableStringBuilder.change(SpannableStringBuilder.java:269)
06-30 16:08:49.616: ERROR/AndroidRuntime(309): at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:432)
06-30 16:08:49.616: ERROR/AndroidRuntime(309): at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:409)
06-30 16:08:49.616: ERROR/AndroidRuntime(309): at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:28)
06-30 16:08:49.616: ERROR/AndroidRuntime(309): at android.text.method.QwertyKeyListener.onKeyDown(QwertyKeyListener.java:195)
06-30 16:08:49.616: ERROR/AndroidRuntime(309): at android.text.method.TextKeyListener.onKeyDown(TextKeyListener.java:132)
06-30 16:08:49.616: ERROR/AndroidRuntime(309): at android.widget.TextView.doKeyDown(TextView.java:4304)
06-30 16:08:49.616: ERROR/AndroidRuntime(309): at android.widget.TextView.onKeyDown(TextView.java:4149)
06-30 16:08:49.616: ERROR/AndroidRuntime(309): at android.view.KeyEvent.dispatch(KeyEvent.java:1037)
06-30 16:08:49.616: ERROR/AndroidRuntime(309): at android.view.View.dispatchKeyEvent(View.java:3740)
06-30 16:08:49.616: ERROR/AndroidRuntime(309): at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:788)
06-30 16:08:49.616: ERROR/AndroidRuntime(309): at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:788)
06-30 16:08:49.616: ERROR/AndroidRuntime(309): at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:788)
06-30 16:08:49.616: ERROR/AndroidRuntime(309): at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:788)
06-30 16:08:49.616: ERROR/AndroidRuntime(309): at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchKeyEvent(PhoneWindow.java:1667)
06-30 16:08:49.616: ERROR/AndroidRuntime(309): at com.android.internal.policy.impl.PhoneWindow.superDispatchKeyEvent(PhoneWindow.java:1102)
06-30 16:08:49.616: ERROR/AndroidRuntime(309): at android.app.Activity.dispatchKeyEvent(Activity.java:2063)
06-30 16:08:49.616: ERROR/AndroidRuntime(309): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchKeyEvent(PhoneWindow.java:1643)
06-30 16:08:49.616: ERROR/AndroidRuntime(309): at android.view.ViewRoot.deliverKeyEventToViewHierarchy(ViewRoot.java:2471)
06-30 16:08:49.616: ERROR/AndroidRuntime(309): at android.view.ViewRoot.handleFinishedEvent(ViewRoot.java:2441)
06-30 16:08:49.616: ERROR/AndroidRuntime(309): at android.view.ViewRoot.handleMessage(ViewRoot.java:1735)
06-30 16:08:49.616: ERROR/AndroidRuntime(309): at android.os.Handler.dispatchMessage(Handler.java:99)
06-30 16:08:49.616: ERROR/AndroidRuntime(309): at android.os.Looper.loop(Looper.java:123)
06-30 16:08:49.616: ERROR/AndroidRuntime(309): at android.app.ActivityThread.main(ActivityThread.java:4627)
06-30 16:08:49.616: ERROR/AndroidRuntime(309): at java.lang.reflect.Method.invokeNative(Native Method)
06-30 16:08:49.616: ERROR/AndroidRuntime(309): at java.lang.reflect.Method.invoke(Method.java:521)
06-30 16:08:49.616: ERROR/AndroidRuntime(309): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
06-30 16:08:49.616: ERROR/AndroidRuntime(309): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
06-30 16:08:49.616: ERROR/AndroidRuntime(309): at dalvik.system.NativeStart.main(Native Method)
06-30 16:08:49.644: WARN/ActivityManager(40): Force finishing activity com.menu.san/.OptionsmenuActivity
06-30 16:08:50.155: WARN/ActivityManager(40): Activity pause timeout for HistoryRecord{4400fa38 com.menu.san/.OptionsmenuActivity}
06-30 16:09:01.335: WARN/ActivityManager(40): Activity destroy timeout for HistoryRecord{4400fa38 com.menu.san/.OptionsmenuActivity}
答案 0 :(得分:0)
请试试这个::: CharSequence cs =“string”; String s = cs.toString(); FOO(一个或多个); //打印“string”
public void foo(CharSequence cs) {
System.out.println(cs);
}