0

我正在使用 LoaderCallbacks 从我的表格中获取所有数据。在得到这样的光标并将其设置在 cursoradapter 中之后。

@Override
public Loader<Cursor> onCreateLoader(int loaderNumber, Bundle bundle) {

        String[] projection = {
                MyDeals.Columns._ID,
                 MyDeals.Columns.LATITUDE,
                MyDeals.Columns.LONGITUDE,
                MyDeals.Columns.PHONENUMBER
                };

        return new CursorLoader(mActivity, MyDeals.CONTENT_URI, projection, null, null, null);  

}

@Override
public void onLoadFinished(Loader<Cursor> cursorLoader, Cursor cursor) {

    dealsBaseAdapter = new DealsBaseAdapter(mActivity, cursor, CursorAdapter.NO_SELECTION);
    mDealListView.setAdapter(dealsBaseAdapter);
}

现在在我的光标适配器中,我想根据距离过滤一些数据。对于我从 db 获取的每个项目。假设如果得到三个数据为

                              Data A , lat_A = 5.5, long_A=5.2
                             Data B , lat_B = 5.5, long_B=5.2
                             Data C , lat_C = 5.5, long_C=5.2

Now based on by present location i calculate the distance between my location and Data A location. if location is <=(someValue) then show deal in list else not.

我从光标获得的所有交易都相同。

在哪个地方我可以像这样过滤我的交易:)

4

1 回答 1

0

请参阅CursorAdapter.setFilterQueryProvider()

于 2013-10-04T07:24:58.400 回答