0
我正在關注@JuanSánchez建議的answer,但我遇到了一個問題。Cursor.getType()API <11問題
當試圖將android.database.Cursor
對象(c)轉換爲CursorWrapper
時,我的問題是ClassCastException
。更具體的代碼行如此CursorWrapper cw = (CursorWrapper)c;
。
CursorWindow cursorWindow = null;
int cursorPosition = 0;
if (android.os.Build.VERSION.SDK_INT < 11) {
CursorWrapper cw = (CursorWrapper)c;
Class<?> cursorWrapper = CursorWrapper.class;
Field mCursor = null;
try {
mCursor = cursorWrapper.getDeclaredField("mCursor");
mCursor.setAccessible(true);
AbstractWindowedCursor abstractWindowedCursor = (AbstractWindowedCursor)mCursor.get(cw);
cursorWindow = abstractWindowedCursor.getWindow();
cursorPosition = abstractWindowedCursor.getPosition();
} catch (NoSuchFieldException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalArgumentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalAccessException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
任何幫助,我將非常感激。
你也可以做'CursorWindow cursorWindow =((AbstractWindowedCursor)光標).getWindow();'。 – JAB