7

我有一些數據光標。我有TextView的可見性取決於光標項的某些屬性。我使用SimpleCursorAdapter並重寫getView方法。但我實際上並不使用SimpleCursorAdapter的屬性。將我的適配器更改爲CursorAdapter並重寫newView和bindView方法會更好嗎?SimpleCursorAdapter vs CursorAdapter?

+3

可能重複[SimpleCursorAdapter和CursorAdapter](http://stackoverflow.com/questions/8382644/simplecursoradapter-and-cursoradapter) – AnV

回答

7

CursorAdapter是抽象的,有待擴展。另一方面,SimpleCursorAdapter不是抽象的。

請注意,newView(上下文上下文,Cursor遊標,ViewGroup父類)在CursorAdapter中是抽象的,但在SimpleCursorAdapter中實現。這是因爲SimpleCursorAdapter具有特定的機制來在CursorAdapter將其留給開發人員時啓動視圖。

來源:SimpleCursorAdapter and CursorAdapter

補充:

I have TextView which visibility depends on some property of the item of cursor.

爲此,您可以檢查SimpleCursorAdapter.ViewBinder接口。

+0

和你會建議使用什麼? – Vahan

+0

我認爲使用'SimpleCursorAdapter'你可以實現你想要的。所以最好使用'SimpleCursorAdapter'。使用'CursorAdapter'你可能不得不做更多的工作。我也更新了我的答案檢查。 –

+0

是的我也試過用viewBinder,但不能確定哪種方法最好,我希望擴展適配器 – Vahan