Example usage for android.support.v4.widget SimpleCursorAdapter SimpleCursorAdapter

List of usage examples for android.support.v4.widget SimpleCursorAdapter SimpleCursorAdapter

Introduction

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

Prototype

public SimpleCursorAdapter(Context context, int layout, Cursor c, String[] from, int[] to, int flags) 

Source Link

Document

Standard constructor.

Usage

From source file:qr.cloud.qrpedia.BookmarksListFragment.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // start loading content
    getLoaderManager().initLoader(BOOKMARKS_LIST_LOADER, null, this);
    String[] bindFrom = { Browser.BookmarkColumns.TITLE, Browser.BookmarkColumns.URL };
    int[] bindTo = { R.id.imported_bookmark_title, R.id.imported_bookmark_url };
    mCursorAdapter = new SimpleCursorAdapter(getActivity(), R.layout.import_bookmarks_row, null, bindFrom,
            bindTo, CursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER);
    setListAdapter(mCursorAdapter);/*from   w w  w.ja  v a  2s  . c  o m*/
}

From source file:io.rapidpro.androidchannel.MessageListFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    m_adapter = new SimpleCursorAdapter(getActivity(), R.layout.command, null,
            new String[] { DBCommandHelper.COL_CMD, DBCommandHelper.COL_CREATED, DBCommandHelper.COL_TITLE,
                    DBCommandHelper.COL_BODY, DBCommandHelper.COL_STATE, DBCommandHelper.COL_STATE,
                    DBCommandHelper.COL_STATE, DBCommandHelper.COL_STATE },
            new int[] { R.id.commandIcon, R.id.commandDate, R.id.commandTitle, R.id.commandBody, R.id.small1,
                    R.id.small2 },//from  w  ww . j a v a2 s .  c o m
            Adapter.NO_SELECTION);

    m_adapter.setViewBinder(new DBCommandViewBinder());

    setListAdapter(m_adapter);
    setListShown(false);
}

From source file:com.pindroid.fragment.BrowseNotesFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    setHasOptionsMenu(true);/* ww w  . java  2  s. c  o  m*/

    mAdapter = new SimpleCursorAdapter(this.getActivity(), R.layout.note_view, null,
            new String[] { Note.Title }, new int[] { R.id.note_title }, 0);

    setListAdapter(mAdapter);

    getLoaderManager().initLoader(0, null, this);

    final ListView lv = getListView();
    lv.setTextFilterEnabled(true);
    lv.setFastScrollEnabled(true);

    lv.setItemsCanFocus(false);
    lv.setChoiceMode(ListView.CHOICE_MODE_SINGLE);

    lv.setOnItemClickListener(new OnItemClickListener() {
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            final Cursor c = (Cursor) lv.getItemAtPosition(position);
            Note n = NoteManager.CursorToNote(c);

            viewNote(n);
        }
    });

    getActivity().setTitle(getString(R.string.browse_my_notes_title));
}

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

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    insertData();/*from ww w .jav  a  2  s  . c om*/

    mAdapter = new SimpleCursorAdapter(this, android.R.layout.two_line_list_item, null, COLUMNS_TO_BE_BOUND,
            LAYOUT_ITEMS_TO_FILL, 0);
    mListView = (ListView) findViewById(R.id.main_list_view);
    mListView.setAdapter(mAdapter);

    // Initializes the loader.
    getSupportLoaderManager().initLoader(CURSOR_LOADER_ID, null, this);
}

From source file:net.yadiary.android.sample.yamaneko.ListFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    CommonUtils.logit("called");
    View view = inflater.inflate(R.layout.list, container);

    String[] from = new String[] { JPostalProvider.FIELD_CODEPREFIX, JPostalProvider.FIELD_CODESUFFIX,
            JPostalProvider.FIELD_PREF, JPostalProvider.FIELD_CITY, JPostalProvider.FIELD_STREET, };
    int[] to = new int[] { R.id.textViewListItemCodeP, R.id.textViewListItemCodeS, R.id.textViewListItemPref,
            R.id.textViewListItemCity, R.id.textViewListItemStreet, };
    adapter = new SimpleCursorAdapter(getActivity(), R.layout.list_item, null, from, to,
            SimpleCursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER);

    ListView listView = (ListView) view.findViewById(R.id.listViewList);
    listView.setAdapter(adapter);/*from w w w  . j a va 2s.c o m*/

    textView = (TextView) view.findViewById(R.id.textViewList);
    updateStatus(0);
    return view;
}

From source file:qr.cloud.qrpedia.SavedTextListFragment.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // start loading content
    getLoaderManager().initLoader(MESSAGE_LIST_LOADER, null, this);
    String[] bindFrom = { QRCloudDatabase.COL_MESSAGE };
    int[] bindTo = { R.id.imported_text };
    mCursorAdapter = new SimpleCursorAdapter(getActivity(), R.layout.import_text_row, null, bindFrom, bindTo,
            CursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER);
    setListAdapter(mCursorAdapter);// w  w w . j  a  va2 s  . c o  m
}

From source file:com.vrj.udacity.dictionaryproviderexample.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    // Get the ListView which will be populated with the Dictionary ContentProvider data.
    ListView listView = (ListView) findViewById(R.id.dictionary_list_view);

    // Get the ContentResolver which will send a message to the ContentProvider
    ContentResolver resolver = getContentResolver();

    // Get a Cursor containing all of the rows in the Words table
    Cursor cursor = resolver.query(UserDictionary.Words.CONTENT_URI, null, null, null, null);

    SimpleCursorAdapter sca = new SimpleCursorAdapter(
            // Context
            this,
            // TextView type that will populate this listview
            android.R.layout.two_line_list_item,
            // The Cursor
            cursor,//w  w  w .ja  v a2s  .  co m
            // String[] of the headers from the table that we want to display
            HEADERS,
            // int[] of the TextViews that we want to display the table values in, in order
            VIEWS,
            // Flags
            0);

    // Set the CursorAdapter for this ListView
    listView.setAdapter(sca);

}

From source file:fr.eoit.activity.fragment.parameter.locationmanagement.AssetsStationListFragment.java

@Override
protected void onLoadFinishedAdapteur(Cursor cursor, SimpleCursorAdapter adapter) {

    refreshAdapteur(new SimpleCursorAdapter(getActivity(), R.layout.station_row_favorite, cursor, dataColumns,
            viewIDs, SimpleCursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER));

    getAdapter().setViewBinder(new StationListViewBinder());
}

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

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    // Get the TextView which will be populated with the Dictionary ContentProvider data.
    ListView dictListView = (ListView) findViewById(R.id.dictionary_list_view);

    // Get the ContentResolver which will send a message to the ContentProvider.
    ContentResolver resolver = getContentResolver();

    // Get a Cursor containing all of the rows in the Words table.
    Cursor cursor = resolver.query(UserDictionary.Words.CONTENT_URI, null, null, null, null);

    // Set the Adapter to fill the standard two_line_list_item layout with data from the Cursor.
    SimpleCursorAdapter adapter = new SimpleCursorAdapter(this, android.R.layout.two_line_list_item, cursor,
            COLUMNS_TO_BE_BOUND, LAYOUT_ITEMS_TO_FILL, 0);

    // Attach the adapter to the ListView.
    dictListView.setAdapter(adapter);/*from w  ww  .  j  av a  2s. c  o m*/
}

From source file:org.uab.deic.uabdroid.fragments.SessionListFragment.java

@Override
public void onActivityCreated(Bundle _savedInstanceState) {
    super.onActivityCreated(_savedInstanceState);

    mParentActivity = getActivity();/*from   w w w  .  j  a va 2s . c om*/

    String locale = Locale.getDefault().toString();

    String keySessionsName = null;
    if (locale.compareTo("ca_ES") == 0) {
        keySessionsName = DatabaseAdapter.KEY_SESSIONS_TITLE_CA;
    } else {
        keySessionsName = DatabaseAdapter.KEY_SESSIONS_TITLE_ES;
    }

    String[] columns = new String[] { DatabaseAdapter.KEY_ROWID, keySessionsName,
            DatabaseAdapter.KEY_SESSIONS_DATE };
    int[] to = new int[] { R.id.txtNumOfSession, R.id.txtName, R.id.txtDate };

    // Now create an array adapter and set it to display using our row
    mCursorAdapter = new SimpleCursorAdapter(mParentActivity, R.layout.element_sessions_list, null, columns, to,
            0);
    setListAdapter(mCursorAdapter);

    mParentActivity.getSupportLoaderManager().initLoader(0, null, new SessionsCursorLoaderCallback());

    // Patch to avoid "flicker" effect.
    getListView().setCacheColorHint(0);
}