Example usage for android.widget SimpleCursorAdapter SimpleCursorAdapter

List of usage examples for android.widget SimpleCursorAdapter SimpleCursorAdapter

Introduction

In this page you can find the example usage for android.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:com.android.messaging.ui.CustomHeaderViewPagerTest.java

public void testBindFirstLevel() {
    final CustomHeaderViewPager view = new CustomHeaderViewPager(getActivity(), null);
    final SimpleCursorAdapter adapter = new SimpleCursorAdapter(getActivity(), 0, null, null, null, 0);
    final CustomHeaderPagerViewHolder[] viewHolders = { new FakeListViewHolder(getActivity(), adapter),
            new FakeListViewHolder(getActivity(), adapter) };

    view.setViewHolders(viewHolders);/*from w  ww . j a  va 2  s . c  o  m*/
    final ViewPager pager = (ViewPager) view.findViewById(R.id.pager);
    final ViewGroup tabStrip = (ViewGroup) view.findViewById(R.id.tab_strip);
    final ViewPagerTabStrip realTab = (ViewPagerTabStrip) tabStrip.getChildAt(0);

    assertEquals(2, realTab.getChildCount());
    View headerTitleButton = realTab.getChildAt(1);
    // Click on the first page. Now the view pager should switch to that page accordingly.
    clickButton(headerTitleButton);
    assertEquals(1, pager.getCurrentItem());
}

From source file:com.misczak.joinmybridge.CalendarFragment.java

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

    setEmptyText("No calendars available.");

    setHasOptionsMenu(true);//from   w w w  .j av a2 s. co  m

    mAdapter = new SimpleCursorAdapter(getActivity(), R.layout.calendar_item, null,
            new String[] { CalendarContract.Calendars.CALENDAR_DISPLAY_NAME,
                    CalendarContract.Calendars.ACCOUNT_NAME },
            new int[] { R.id.calendarDisplayName, R.id.calendarAccountName }, 0);
    setListAdapter(mAdapter);

    setListShown(false);

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

From source file:com.commonsware.android.dbasset.ConstantsFragment.java

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    SimpleCursorAdapter adapter = new SimpleCursorAdapter(getActivity(), R.layout.row, current,
            new String[] { DatabaseHelper.TITLE, DatabaseHelper.VALUE }, new int[] { R.id.title, R.id.value },
            0);/*from w  ww . j av a  2  s  . c  om*/

    setListAdapter(adapter);

    if (current == null) {
        db = new DatabaseHelper(getActivity());
        task = new LoadCursorTask().execute();
    }
}

From source file:de.escoand.readdaily.AbstractContentFragment.java

@Override
public View onCreateView(final LayoutInflater inflater, @Nullable final ViewGroup container,
        @Nullable final Bundle savedInstanceState) {
    adapter = new SimpleCursorAdapter(getContext(), layout, null, from, to, 0);
    adapter.setViewBinder(this);
    adapter.changeCursor(cursor);/*from   w  w  w. j av  a2  s  . c  o  m*/

    if (savedInstanceState != null)
        onDateSelected(Database.getDateFromInt(savedInstanceState.getInt(STATE_DATE)));

    ListView list = new ListView(getContext());
    list.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));
    list.setAdapter(adapter);

    return list;
}

From source file:com.example.ward.view.CursorFragment.java

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

    // Give some text to display if there is no data.  In a real
    // application this would come from a resource.
    setEmptyText("No phone numbers");

    // We have a menu item to show in action bar.
    setHasOptionsMenu(true);//from   w  w  w .  j  av a 2 s.c  om

    // Create an empty adapter we will use to display the loaded data.
    mAdapter = new SimpleCursorAdapter(getActivity(), android.R.layout.simple_list_item_2, null,
            new String[] { Contacts.DISPLAY_NAME, Contacts.CONTACT_STATUS },
            new int[] { android.R.id.text1, android.R.id.text2 }, 0);
    setListAdapter(mAdapter);

    // Start out with a progress indicator.
    setListShown(false);

    // Prepare the loader.  Either re-connect with an existing one,
    // or start a new one.
    getLoaderManager().initLoader(0, null, this);
}

From source file:com.example.diego.activitytracker.HeadlinesFragment.java

private void displayListView() {

    Cursor cursor = dbHelper.fetchAllHeadlines();

    String[] columns = new String[] { DbAdapter.KEY_HEADLINE };

    int[] to = new int[] { R.id.headline };

    dataAdapter = new SimpleCursorAdapter(getActivity(), R.layout.headline_title, cursor, columns, to, 0);

    setListAdapter(dataAdapter);/*ww w. j a  va  2 s  .c  o m*/
}

From source file:de.escoand.readdaily.ListDialogFragment.java

@NonNull
@Override// www  .jav a2 s  .c  o  m
public Dialog onCreateDialog(final Bundle savedInstanceState) {
    if (title == null)
        title = getString(R.string.navigation_list);

    // adapter
    adapter = new SimpleCursorAdapter(getContext(), R.layout.item_dialog,
            Database.getInstance(getContext()).getList(condition, values, order), from, to, 0);
    adapter.setViewBinder(this);

    // dialog
    return new AlertDialog.Builder(getContext()).setTitle(title).setAdapter(adapter, this)
            .setNegativeButton(R.string.button_cancel, null).create();
}

From source file:com.commonsware.android.fts.QuestionsFragment.java

@Override
public void onViewCreated(View view, Bundle state) {
    super.onViewCreated(view, state);

    SimpleCursorAdapter adapter = new SimpleCursorAdapter(getActivity(), R.layout.row, null,
            new String[] { DatabaseHelper.TITLE, DatabaseHelper.PROFILE_IMAGE },
            new int[] { R.id.title, R.id.icon }, 0);

    adapter.setViewBinder(new QuestionBinder());
    setListAdapter(adapter);//from www .  j  a  va  2  s .  com
}

From source file:com.misczak.joinmybridge.EventFragment.java

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

    setEmptyText("No events available.");

    setHasOptionsMenu(true);// ww  w . ja v a 2  s.  c o m

    mAdapter = new SimpleCursorAdapter(getActivity(), R.layout.event_item, null,
            new String[] { CalendarContract.Events.TITLE, CalendarContract.Events.EVENT_LOCATION },
            new int[] { R.id.eventTitle, R.id.eventLocation }, 0);
    setListAdapter(mAdapter);

    setListShown(false);

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

From source file:com.mysmallcornerstudios.tempus.ui.MainActivity.java

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

    title = drawerTitle = getTitle();/*from w w  w .j a  v a2 s.  c  o m*/

    getSupportLoaderManager().initLoader(TIMER_LOADER, savedInstanceState, this);

    final String[] timerFromColumns = { ID, NAME, DURATION, ALARM_COUNT };
    final int[] timerToViews = { R.id.timer_row_id, R.id.timer_name, R.id.timer_duration,
            R.id.timer_alarm_count };

    timerCursorAdapter = new SimpleCursorAdapter(this, R.layout.drawer_list_item, null, timerFromColumns,
            timerToViews, 0);
    timerList = (ListView) findViewById(R.id.left_drawer);
    timerList.setAdapter(timerCursorAdapter);
    timerList.setOnItemClickListener(new DrawerItemClickListener());

    getActionBar().setDisplayHomeAsUpEnabled(true);
    getActionBar().setHomeButtonEnabled(true);

    drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    drawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);
    drawerToggle = new ActionBarDrawerToggle(this, /* host Activity */
            drawerLayout, /* DrawerLayout object */
            R.drawable.ic_drawer, /* nav drawer image to replace 'Up' caret */
            R.string.drawer_open, /* "open drawer" description for accessibility */
            R.string.drawer_close /* "close drawer" description for accessibility */
    ) {
        public void onDrawerClosed(View view) {
            getActionBar().setTitle(title);
            invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu()
        }

        public void onDrawerOpened(View drawerView) {
            getActionBar().setTitle(drawerTitle);
            invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu()
        }
    };
    drawerLayout.setDrawerListener(drawerToggle);

    if (savedInstanceState == null) {
        //            selectItem(0, 0, "Tempus", "", 0);
    }
}