Java Code Examples for android.widget.SimpleCursorAdapter#swapCursor()

The following examples show how to use android.widget.SimpleCursorAdapter#swapCursor() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: VmMigrateActivity.java    From moVirt with Apache License 2.0 6 votes vote down vote up
private void setLoader(final String filterClusterId, final String filterHostId) {
    hostsAdapter = new SimpleCursorAdapter(this,
            android.R.layout.simple_list_item_activated_1, null,
            new String[]{OVirtContract.Host.NAME}, new int[]{android.R.id.text1}, 0);
    cursorAdapterLoader = new CursorAdapterLoader(hostsAdapter) {
        @Override
        public synchronized Loader<Cursor> onCreateLoader(int id, Bundle args) {
            return provider.query(Host.class)
                    .where(Host.STATUS, HostStatus.UP.toString())
                    .where(Host.CLUSTER_ID, filterClusterId)
                    .where(Host.ID, filterHostId, Relation.NOT_EQUAL).asLoader();
        }

        @Override
        public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
            hostsAdapter.swapCursor(data);
            if (data != null && data.getCount() > 0) {
                enableViews();
            }
        }
    };
    getSupportLoaderManager().initLoader(HOSTS_LOADER, null, cursorAdapterLoader);
}
 
Example 2
Source File: HistoryActivity.java    From Finder with GNU General Public License v3.0 4 votes vote down vote up
private void updateList(String sql, SimpleCursorAdapter adapt) {
    Cursor temp_cursor = db.rawQuery(sql, null);
    adapt.swapCursor(temp_cursor);
    adapt.notifyDataSetChanged();
}