Example usage for android.widget SimpleCursorAdapter notifyDataSetChanged

List of usage examples for android.widget SimpleCursorAdapter notifyDataSetChanged

Introduction

In this page you can find the example usage for android.widget SimpleCursorAdapter notifyDataSetChanged.

Prototype

public void notifyDataSetChanged() 

Source Link

Document

Notifies the attached observers that the underlying data has been changed and any View reflecting the data set should refresh itself.

Usage

From source file:eu.thecoder4.gpl.pleftdroid.PleftDroidActivity.java

private void fillList() {
    mDbAdapter.open();/*from   w w w  .  j a  v a 2s .co  m*/
    // Get all of the appointments from the database and create the item list
    Cursor c = mDbAdapter.fetchAllAppointmentsList();
    startManagingCursor(c);
    if (c.getCount() > 0) {

        String[] from = null;
        int[] to = null;
        SimpleCursorAdapter apts = null;
        if (isPrefDetailListSet()) {
            from = new String[] { PleftDroidDbAdapter.COL_DESC, PleftDroidDbAdapter.COL_ROLE,
                    PleftDroidDbAdapter.COL_STATUS, PleftDroidDbAdapter.COL_PSERVER,
                    PleftDroidDbAdapter.COL_USER };
            to = new int[] { R.id.adesc, R.id.arole, R.id.astatus, R.id.apserver, R.id.auser };
            // Now create an array adapter and set it to display using our row
            apts = new SimpleCursorAdapter(this, R.layout.event_row_details, c, from, to);
        } else {
            from = new String[] { PleftDroidDbAdapter.COL_DESC, PleftDroidDbAdapter.COL_ROLE,
                    PleftDroidDbAdapter.COL_STATUS };
            to = new int[] { R.id.adesc, R.id.arole, R.id.astatus };
            // Now create an array adapter and set it to display using our row
            apts = new SimpleCursorAdapter(this, R.layout.event_row, c, from, to);
        }
        this.getListView().destroyDrawingCache();
        this.getListView().setVisibility(ListView.INVISIBLE);
        this.getListView().setVisibility(ListView.VISIBLE);
        this.getWindow().getDecorView().invalidate();

        setListAdapter(apts);
        apts.notifyDataSetChanged();
    }
    mDbAdapter.close();
}

From source file:com.esri.android.mapsapp.MapFragment.java

/**
 * Set the suggestion cursor to an Adapter then set it to the search view
 *///from   w w  w  .j ava  2s  . co m
private void applySuggestionCursor() {
    String[] cols = new String[] { COLUMN_NAME_ADDRESS };
    int[] to = new int[] { R.id.suggestion_item_address };

    SimpleCursorAdapter mSuggestionAdapter = new SimpleCursorAdapter(mMapView.getContext(),
            R.layout.search_suggestion_item, mSuggestionCursor, cols, to, 0);
    mSearchview.setSuggestionsAdapter(mSuggestionAdapter);
    mSuggestionAdapter.notifyDataSetChanged();
}

From source file:com.example.android.lightcontrol.MainActivity.java

private void light_configure() {
    LayoutInflater inflater = LayoutInflater.from(this);
    final View v = inflater.inflate(R.layout.light_configure, null);
    final AlertDialog.Builder dialog = new AlertDialog.Builder(this);
    helper = new DBHelper(getApplicationContext());
    cursor = helper.select(TABLE_NAME_DALISLAVEADDRESS);
    final EditText change_light_name = (EditText) v.findViewById(R.id.editText3);

    Button change_name = (Button) v.findViewById(R.id.button3);

    final Spinner light_list = (Spinner) v.findViewById(R.id.light_list);

    final SimpleCursorAdapter adapter = new SimpleCursorAdapter(MainActivity.this, R.layout.message, cursor,
            new String[] { "_dali_name" }, new int[] { R.id.message });
    light_list.setAdapter(adapter);/*from   w w w. j  a v a2  s .  co  m*/

    light_list.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {

            cursor.moveToPosition(i);
        }

        @Override
        public void onNothingSelected(AdapterView<?> adapterView) {

        }
    });

    change_name.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View view) {

            helper.update(cursor.getInt(0), TABLE_NAME_DALISLAVEADDRESS, FEILD_NAME_DALI,
                    String.valueOf(change_light_name.getText()));
            helper.close();
            cursor.close();
            helper = new DBHelper(getApplicationContext());
            cursor = helper.select(TABLE_NAME_DALISLAVEADDRESS);
            adapter.notifyDataSetChanged();
            final Spinner light_list = (Spinner) v.findViewById(R.id.light_list);
            final SimpleCursorAdapter adapter = new SimpleCursorAdapter(MainActivity.this, R.layout.message,
                    cursor, new String[] { "_dali_name" }, new int[] { R.id.message });
            light_list.setAdapter(adapter);

        }
    });

    dialog.setCancelable(false);
    dialog.setTitle(R.string.about_title);
    dialog.setView(v);
    dialog.setPositiveButton(R.string.ok_label_1, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialoginterface, int i) {
            updatespinner();
            helper.close();
            cursor.close();
        }
    });
    dialog.show();

}