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

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

Introduction

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

Prototype

public void setDropDownViewResource(int dropDownLayout) 

Source Link

Document

Sets the layout resource of the drop down views.

Usage

From source file:org.gnucash.android.ui.transactions.BulkMoveDialogFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    getDialog().getWindow().setLayout(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);

    Bundle args = getArguments();//from  www  .ja v  a2s . c  om
    mTransactionIds = args.getLongArray(TransactionsListFragment.SELECTED_TRANSACTION_IDS);
    mOriginAccountId = args.getLong(TransactionsListFragment.ORIGIN_ACCOUNT_ID);

    String title = getActivity().getString(R.string.title_move_transactions, mTransactionIds.length);
    getDialog().setTitle(title);

    mAccountsDbAdapter = new AccountsDbAdapter(getActivity());
    Cursor cursor = mAccountsDbAdapter.fetchAllAccounts();

    String[] from = new String[] { DatabaseHelper.KEY_NAME };
    int[] to = new int[] { android.R.id.text1 };
    SimpleCursorAdapter mCursorAdapter = new SimpleCursorAdapter(getActivity(),
            android.R.layout.simple_spinner_item, cursor, from, to, 0);
    mCursorAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    mDestinationAccountSpinner.setAdapter(mCursorAdapter);
    setListeners();
}

From source file:org.gnucash.android.ui.transaction.BulkMoveDialogFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    getDialog().getWindow().setLayout(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);

    Bundle args = getArguments();/*from w w w .  j a  va 2  s. c  o  m*/
    mTransactionIds = args.getLongArray(UxArgument.SELECTED_TRANSACTION_IDS);
    mOriginAccountId = args.getLong(UxArgument.ORIGIN_ACCOUNT_ID);

    String title = getActivity().getString(R.string.title_move_transactions, mTransactionIds.length);
    getDialog().setTitle(title);

    mAccountsDbAdapter = new AccountsDbAdapter(getActivity());
    String conditions = "(" + DatabaseHelper.KEY_ROW_ID + " != " + mOriginAccountId + " AND "
            + DatabaseHelper.KEY_CURRENCY_CODE + " = '" + mAccountsDbAdapter.getCurrencyCode(mOriginAccountId)
            + "' AND " + DatabaseHelper.KEY_UID + " != '" + mAccountsDbAdapter.getGnuCashRootAccountUID()
            + "' AND " + DatabaseHelper.KEY_PLACEHOLDER + " = 0" + ")";
    Cursor cursor = mAccountsDbAdapter.fetchAccountsOrderedByFullName(conditions);

    SimpleCursorAdapter mCursorAdapter = new QualifiedAccountNameCursorAdapter(getActivity(),
            android.R.layout.simple_spinner_item, cursor);
    mCursorAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    mDestinationAccountSpinner.setAdapter(mCursorAdapter);
    setListeners();
}

From source file:org.gnucash.android.ui.transaction.dialog.BulkMoveDialogFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    getDialog().getWindow().setLayout(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);

    Bundle args = getArguments();/*from   w w w . j  a  v  a  2  s .  c o  m*/
    mTransactionIds = args.getLongArray(UxArgument.SELECTED_TRANSACTION_IDS);
    mOriginAccountUID = args.getString(UxArgument.ORIGIN_ACCOUNT_UID);

    String title = getActivity().getString(R.string.title_move_transactions, mTransactionIds.length);
    getDialog().setTitle(title);

    mAccountsDbAdapter = new AccountsDbAdapter(getActivity());
    String conditions = "(" + DatabaseSchema.AccountEntry.COLUMN_UID + " != '" + mOriginAccountUID + "' AND "
            + DatabaseSchema.AccountEntry.COLUMN_CURRENCY + " = '"
            + mAccountsDbAdapter.getCurrencyCode(mOriginAccountUID) + "' AND "
            + DatabaseSchema.AccountEntry.COLUMN_UID + " != '" + mAccountsDbAdapter.getGnuCashRootAccountUID()
            + "' AND " + DatabaseSchema.AccountEntry.COLUMN_PLACEHOLDER + " = 0" + ")";
    Cursor cursor = mAccountsDbAdapter.fetchAccountsOrderedByFullName(conditions);

    SimpleCursorAdapter mCursorAdapter = new QualifiedAccountNameCursorAdapter(getActivity(),
            android.R.layout.simple_spinner_item, cursor);
    mCursorAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    mDestinationAccountSpinner.setAdapter(mCursorAdapter);
    setListeners();
}

From source file:com.dpcsoftware.mn.Widget1Config.java

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

    setResult(RESULT_CANCELED);/* w  ww.  j a v a  2  s  .  c om*/

    wPrefs = getSharedPreferences(App.WIDGET_PREFS_FNAME, MODE_PRIVATE);

    Intent intent = getIntent();
    Bundle extras = intent.getExtras();
    wId = AppWidgetManager.INVALID_APPWIDGET_ID;
    if (extras != null)
        wId = extras.getInt(AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID);
    else
        finish();

    setContentView(R.layout.widget1_config);

    resultIntent = new Intent();
    resultIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, wId);

    ActionBar abar = getSupportActionBar();
    abar.setTitle("Configuraes do Widget");

    SQLiteDatabase db = DatabaseHelper.quickDb(this, DatabaseHelper.MODE_READ);
    Cursor c = db.rawQuery("SELECT " + Db.Table3._ID + "," + Db.Table3.COLUMN_NGRUPO + " FROM "
            + Db.Table3.TABLE_NAME + " ORDER BY " + Db.Table3.COLUMN_NGRUPO + " ASC", null);

    SimpleCursorAdapter sAdapter = new SimpleCursorAdapter(this, android.R.layout.simple_spinner_item, c,
            new String[] { Db.Table3.COLUMN_NGRUPO }, new int[] { android.R.id.text1 }, 0);
    sAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    sp = ((Spinner) findViewById(R.id.spinner1));
    sp.setAdapter(sAdapter);
}

From source file:org.gnucash.android.ui.widget.WidgetConfigurationActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.widget_configuration);
    setResult(RESULT_CANCELED);//  www.j a va2 s  .co  m

    mAccountsSpinner = (Spinner) findViewById(R.id.input_accounts_spinner);
    mOkButton = (Button) findViewById(R.id.btn_save);
    mCancelButton = (Button) findViewById(R.id.btn_cancel);

    mAccountsDbAdapter = new AccountsDbAdapter(this);
    Cursor cursor = mAccountsDbAdapter.fetchAllRecordsOrderedByFullName();

    if (cursor.getCount() <= 0) {
        Toast.makeText(this, R.string.error_no_accounts, Toast.LENGTH_LONG).show();
        finish();
    }

    SimpleCursorAdapter cursorAdapter = new QualifiedAccountNameCursorAdapter(this,
            android.R.layout.simple_spinner_item, cursor);
    cursorAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    mAccountsSpinner.setAdapter(cursorAdapter);

    bindListeners();
}

From source file:fr.eoit.activity.fragment.blueprint.RequiredDecryptorFragment.java

@Override
public void onLoadFinished(Cursor cursor) {
    if (DbUtil.hasAtLeastOneRow(cursor)) {
        String[] from = new String[] { Item.COLUMN_NAME_NAME, "decryptorDesc" };
        int[] to = new int[] { android.R.id.text1, android.R.id.text2 };

        MatrixCursor decryptorCursor = new MatrixCursor(
                new String[] { Item._ID, Item.COLUMN_NAME_NAME, "decryptorDesc" });
        DbUtil.addRowToMatrixCursor(decryptorCursor, 0L, "None", "");

        cursor.moveToFirst();//from   w  w w. ja va 2s . com
        int selectedItem = 0;
        while (!cursor.isAfterLast()) {
            long itemId = cursor.getLong(cursor.getColumnIndexOrThrow(Item._ID));
            DbUtil.addRowToMatrixCursor(decryptorCursor, itemId,
                    cursor.getString(cursor.getColumnIndexOrThrow(Item.COLUMN_NAME_NAME)),
                    getDecryptorDescription(DecryptorUtil.getDecryptorBonuses(itemId),
                            getActivity().getResources()));

            if (itemId == decryptorId) {
                selectedItem = cursor.getPosition() + 1;
            }

            cursor.moveToNext();
        }

        SimpleCursorAdapter adapter = new SimpleCursorAdapter(getActivity(),
                android.R.layout.simple_spinner_item, decryptorCursor, from, to,
                SimpleCursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER);
        Spinner spinner = (Spinner) getActivity().findViewById(R.id.DECRYPTOR_SPINNER);
        adapter.setDropDownViewResource(R.layout.decryptor_drop_down_item);
        spinner.setAdapter(adapter);
        spinner.setOnItemSelectedListener(new SpinnerDecryptorOnItemSelectedListener());
        spinner.setSelection(selectedItem);
    }
}

From source file:com.heneryh.aquanotes.ui.feed.FeedActivity.java

private void fillSpinner() {

    Uri controllersQueryUri = Controllers.buildQueryControllersUri();
    Cursor cursor = dbResolverFeedAct.query(controllersQueryUri, ControllersQuery.PROJECTION, null, null, null);

    startManagingCursor(cursor);//from w w w. j a v  a 2  s  .co m

    // create an array to specify which fields we want to display
    String[] from = new String[] { ControllersQuery.PROJECTION[ControllersQuery.TITLE] };
    // create an array of the display item we want to bind our data to
    int[] to = new int[] { android.R.id.text1 };
    // create simple cursor adapter
    @SuppressWarnings("deprecation")
    SimpleCursorAdapter adapter = new SimpleCursorAdapter(this, android.R.layout.simple_spinner_item, cursor,
            from, to);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    // get reference to our spinner
    Spinner s = (Spinner) findViewById(R.id.ctrlr_id);
    s.setAdapter(adapter);
}

From source file:org.gnucash.android.ui.homescreen.WidgetConfigurationActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.widget_configuration);
    setResult(RESULT_CANCELED);/* w  w w . j  a  v  a  2s  . c o  m*/

    ButterKnife.bind(this);

    BooksDbAdapter booksDbAdapter = BooksDbAdapter.getInstance();
    Cursor booksCursor = booksDbAdapter.fetchAllRecords();
    String currentBookUID = booksDbAdapter.getActiveBookUID();

    //determine the position of the currently active book in the cursor
    int position = 0;
    while (booksCursor.moveToNext()) {
        String bookUID = booksCursor
                .getString(booksCursor.getColumnIndexOrThrow(DatabaseSchema.BookEntry.COLUMN_UID));
        if (bookUID.equals(currentBookUID))
            break;
        ++position;
    }

    SimpleCursorAdapter booksCursorAdapter = new SimpleCursorAdapter(this, android.R.layout.simple_spinner_item,
            booksCursor, new String[] { DatabaseSchema.BookEntry.COLUMN_DISPLAY_NAME },
            new int[] { android.R.id.text1 }, 0);
    booksCursorAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    mBooksSpinner.setAdapter(booksCursorAdapter);
    mBooksSpinner.setSelection(position);

    mAccountsDbAdapter = AccountsDbAdapter.getInstance();
    Cursor cursor = mAccountsDbAdapter.fetchAllRecordsOrderedByFullName();

    if (cursor.getCount() <= 0) {
        Toast.makeText(this, R.string.error_no_accounts, Toast.LENGTH_LONG).show();
        finish();
    }

    mAccountsCursorAdapter = new QualifiedAccountNameCursorAdapter(this, cursor);
    //without this line, the app crashes when a user tries to select an account
    mAccountsCursorAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    mAccountsSpinner.setAdapter(mAccountsCursorAdapter);

    boolean passcodeEnabled = PreferenceManager.getDefaultSharedPreferences(getApplicationContext())
            .getBoolean(UxArgument.ENABLED_PASSCODE, false);
    mHideAccountBalance.setChecked(passcodeEnabled);

    bindListeners();
}

From source file:info.guardianproject.otr.app.im.app.AddContactActivity.java

private void setupAccountSpinner() {
    final Uri uri = Imps.Provider.CONTENT_URI_WITH_ACCOUNT;

    mCursorProviders = managedQuery(uri, PROVIDER_PROJECTION,
            Imps.Provider.CATEGORY + "=?" + " AND " + Imps.Provider.ACTIVE_ACCOUNT_USERNAME
                    + " NOT NULL" /* selection */,
            new String[] { ImApp.IMPS_CATEGORY } /* selection args */, Imps.Provider.DEFAULT_SORT_ORDER);

    SimpleCursorAdapter adapter = new SimpleCursorAdapter(this, android.R.layout.simple_spinner_item,
            mCursorProviders, new String[] { Imps.Provider.ACTIVE_ACCOUNT_USERNAME },
            new int[] { android.R.id.text1 });
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

    // TODO Something is causing the managedQuery() to return null, use null guard for now
    if (mCursorProviders != null && mCursorProviders.getCount() > 0) {
        mCursorProviders.moveToFirst();/*  www. j  ava2 s .c om*/
        mProviderId = mCursorProviders.getLong(PROVIDER_ID_COLUMN);
        mAccountId = mCursorProviders.getLong(ACTIVE_ACCOUNT_ID_COLUMN);
    }

    mListSpinner.setAdapter(adapter);
    mListSpinner.setOnItemSelectedListener(new OnItemSelectedListener() {

        @Override
        public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
            if (mCursorProviders == null)
                return;
            mCursorProviders.moveToPosition(arg2);
            mProviderId = mCursorProviders.getLong(PROVIDER_ID_COLUMN);
            mAccountId = mCursorProviders.getLong(ACTIVE_ACCOUNT_ID_COLUMN);
        }

        @Override
        public void onNothingSelected(AdapterView<?> arg0) {
            // TODO Auto-generated method stub

        }
    });

}

From source file:org.awesomeapp.messenger.ui.AddContactActivity.java

private void setupAccountSpinner() {
    final Uri uri = Imps.Provider.CONTENT_URI_WITH_ACCOUNT;

    mCursorProviders = managedQuery(uri, PROVIDER_PROJECTION,
            Imps.Provider.CATEGORY + "=?" + " AND " + Imps.Provider.ACTIVE_ACCOUNT_USERNAME
                    + " NOT NULL" /* selection */,
            new String[] { ImApp.IMPS_CATEGORY } /* selection args */, Imps.Provider.DEFAULT_SORT_ORDER);

    SimpleCursorAdapter adapter = new SimpleCursorAdapter(this, android.R.layout.simple_spinner_item,
            mCursorProviders, new String[] { Imps.Provider.ACTIVE_ACCOUNT_USERNAME },
            new int[] { android.R.id.text1 });
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

    // TODO Something is causing the managedQuery() to return null, use null guard for now
    if (mCursorProviders != null && mCursorProviders.getCount() > 0) {
        mCursorProviders.moveToFirst();//from   ww  w  .j a v  a2 s. c  o  m
        mProviderId = mCursorProviders.getLong(PROVIDER_ID_COLUMN);
        mAccountId = mCursorProviders.getLong(ACTIVE_ACCOUNT_ID_COLUMN);
    }

    /**
    mListSpinner.setAdapter(adapter);
    mListSpinner.setOnItemSelectedListener(new OnItemSelectedListener() {
            
    @Override
    public void onItemSelected(AdapterView<?> arg0, View arg1,
            int arg2, long arg3) {
        if (mCursorProviders == null)
            return;
        mCursorProviders.moveToPosition(arg2);
        mProviderId = mCursorProviders.getLong(PROVIDER_ID_COLUMN);
        mAccountId = mCursorProviders.getLong(ACTIVE_ACCOUNT_ID_COLUMN);
     }
            
    @Override
    public void onNothingSelected(AdapterView<?> arg0) {
        // TODO Auto-generated method stub
            
    }
    });
    */
}