-3
我正在使用搜索來顯示列表視圖內容。當單擊搜索功能或鍵入任何數據時,它會顯示我的應用程序已停止。單擊搜索時,我的應用程序已停止
Mainactivity.java
@SuppressLint("NewApi")
@SuppressWarnings("deprecation")
private void fillData(Cursor projectsCursor) {
//mDbHelper.open();
if(projectsCursor!=null)
{
String[] from = new String[]{GinfyDbAdapter.CATEGORY_COLUMN_TITLE, GinfyDbAdapter.CATEGORY_COLUMN_CONTENT, GinfyDbAdapter.CATEGORY_COLUMN_COUNT};
int[] to = new int[]{R.id.text2, R.id.text1, R.id.count};
dataAdapter = new SimpleCursorAdapter(
this, R.layout.activity_row,
projectsCursor,
from,
to,
0);
setListAdapter(dataAdapter);
EditText myFilter = (EditText) findViewById(R.id.myFilter);
myFilter.addTextChangedListener(new TextWatcher() {
public void afterTextChanged(Editable s) {
}
public void beforeTextChanged(CharSequence s, int start,
int count, int after) {
}
public void onTextChanged(CharSequence s, int start,
int before, int count) {
dataAdapter.getFilter().filter(s.toString());
}
});
dataAdapter.setFilterQueryProvider(new FilterQueryProvider() {
public Cursor runQuery(CharSequence constraint) {
return mDbHelper.fetchProjectByName(constraint.toString());
}
});
這是我db.java
public Cursor fetchProjectByName(String inputText) throws SQLException {
Log.w(TAG, inputText);
Cursor mCursor = null;
if (inputText == null || inputText.length() == 0) {
mCursor = mDb.query(DATABASE_TABLE_PROJ, new String[] {CATEGORY_COLUMN_ID,
CATEGORY_COLUMN_CONTENT},
null, null, null, null, null);
}
else {
mCursor = mDb.query(true, DATABASE_TABLE_PROJ, new String[] {CATEGORY_COLUMN_ID,
CATEGORY_COLUMN_CONTENT},
CATEGORY_COLUMN_CONTENT + " like '%" + inputText + "%'", null,
null, null, null, null);
}
if (mCursor != null) {
mCursor.moveToFirst();
}
return mCursor;
}
按名稱fetchproject使用DB我要搜索列表視圖的內容將匹配根據我的搜索option.It顯示一些logcaterror。 鍵入或單擊搜索區域時,它會顯示我的應用程序已停止。
這是我的logcat錯誤。
07-15 12:23:08.688: E/AndroidRuntime(25812): FATAL EXCEPTION: main
07-15 12:23:08.688: E/AndroidRuntime(25812): java.lang.IllegalArgumentException: column 'title' does not exist
07-15 12:23:08.688: E/AndroidRuntime(25812): at android.database.AbstractCursor.getColumnIndexOrThrow(AbstractCursor.java:303)
07-15 12:23:08.688: E/AndroidRuntime(25812): at android.widget.SimpleCursorAdapter.findColumns(SimpleCursorAdapter.java:333)
07-15 12:23:08.688: E/AndroidRuntime(25812): at android.widget.SimpleCursorAdapter.swapCursor(SimpleCursorAdapter.java:345)
07-15 12:23:08.688: E/AndroidRuntime(25812): at android.widget.CursorAdapter.changeCursor(CursorAdapter.java:309)
07-15 12:23:08.688: E/AndroidRuntime(25812): at android.widget.CursorFilter.publishResults(CursorFilter.java:67)
07-15 12:23:08.688: E/AndroidRuntime(25812): at android.widget.Filter$ResultsHandler.handleMessage(Filter.java:282)
07-15 12:23:08.688: E/AndroidRuntime(25812): at android.os.Handler.dispatchMessage(Handler.java:99)
07-15 12:23:08.688: E/AndroidRuntime(25812): at android.os.Looper.loop(Looper.java:137)
07-15 12:23:08.688: E/AndroidRuntime(25812): at android.app.ActivityThread.main(ActivityThread.java:5039)
07-15 12:23:08.688: E/AndroidRuntime(25812): at java.lang.reflect.Method.invokeNative(Native Method)
07-15 12:23:08.688: E/AndroidRuntime(25812): at java.lang.reflect.Method.invoke(Method.java:511)
07-15 12:23:08.688: E/AndroidRuntime(25812): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
07-15 12:23:08.688: E/AndroidRuntime(25812): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
07-15 12:23:08.688: E/AndroidRuntime(25812): at dalvik.system.NativeStart.main(Native Method)
在查詢投影 – Tarun
其中夥計,這裏我要補充 –
@Tarun http://pastebin.com/jb1BA94g在這裏,我貼我的全部代碼,在那裏我要補充花花公子 –