Example usage for android.widget SimpleCursorAdapter setDropDownViewResource

List of usage examples for android.widget SimpleCursorAdapter setDropDownViewResource

Introduction

In this page you can find the example usage for android.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:com.rightscale.app.dashboard.ShowServerMonitoring.java

public void consumeContent(Cursor cursor, String tag) {
    super.consumeContent(cursor, tag);

    if (tag == MONITORS) {
        _cursor = cursor;/*from   w  ww  .  j a  v a 2 s. c o  m*/
        startManagingCursor(cursor);
        SimpleCursorAdapter adapter = new SimpleCursorAdapter(this, android.R.layout.simple_spinner_item,
                cursor, FROM, TO);
        adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        Spinner spinner = (Spinner) findViewById(R.id.show_server_monitoring_spinner);
        spinner.setEnabled(true);
        spinner.setAdapter(adapter);
        spinner.setOnItemSelectedListener(new OnItemSelectedListener() {
            public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
                int colHref = _cursor.getColumnIndexOrThrow("href");
                _cursor.moveToPosition(position);
                String href = _cursor.getString(colHref);
                showGraph(href, DEFAULT_SIZE, DEFAULT_PERIOD);
            }

            public void onNothingSelected(AdapterView<?> arg0) {
                //TODO: clear the monitoring graph (fade out, oooh!)
            }
        });
    }
}

From source file:com.iskrembilen.quasseldroid.gui.LoginActivity.java

/** Called when the activity is first created. */
@Override//from   w ww  .  ja v  a  2 s.c  o m
public void onCreate(Bundle savedInstanceState) {
    setTheme(ThemeUtil.theme);
    super.onCreate(savedInstanceState);
    currentTheme = ThemeUtil.theme;
    setContentView(R.layout.login);

    settings = getSharedPreferences(PREFS_ACCOUNT, MODE_PRIVATE);
    dbHelper = new QuasselDbHelper(this);
    dbHelper.open();

    core = (Spinner) findViewById(R.id.serverSpinner);
    username = (EditText) findViewById(R.id.usernameField);
    password = (EditText) findViewById(R.id.passwordField);
    rememberMe = (CheckBox) findViewById(R.id.remember_me_checkbox);

    //setup the core spinner
    Cursor c = dbHelper.getAllCores();
    startManagingCursor(c);

    String[] from = new String[] { QuasselDbHelper.KEY_NAME };
    int[] to = new int[] { android.R.id.text1 };
    SimpleCursorAdapter adapter = new SimpleCursorAdapter(this, android.R.layout.simple_spinner_item, c, from,
            to);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    //TODO: Ken:Implement view reuse
    core.setAdapter(adapter);

    //Use saved settings
    if (core.getCount() > settings.getInt(PREFS_CORE, 0))
        core.setSelection(settings.getInt(PREFS_CORE, 0));
    username.setText(settings.getString(PREFS_USERNAME, ""));
    password.setText(settings.getString(PREFS_PASSWORD, ""));
    rememberMe.setChecked(settings.getBoolean(PREFS_REMEMBERME, false));

    connect = (Button) findViewById(R.id.connect_button);
    connect.setOnClickListener(onConnect);
}

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

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

    final Cursor cursorProviders = 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_dropdown_item,
            cursorProviders, new String[] { Imps.Provider.ACTIVE_ACCOUNT_USERNAME },
            new int[] { android.R.id.text1 });
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

    if (cursorProviders.getCount() > 0) {
        cursorProviders.moveToFirst();/*ww w . j a v  a 2s  .co m*/
        mLastProviderId = cursorProviders.getLong(PROVIDER_ID_COLUMN);
        mLastAccountId = cursorProviders.getLong(ACTIVE_ACCOUNT_ID_COLUMN);

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

            @Override
            public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
                cursorProviders.moveToPosition(arg2);

                mLastProviderId = cursorProviders.getLong(PROVIDER_ID_COLUMN);
                mLastAccountId = cursorProviders.getLong(ACTIVE_ACCOUNT_ID_COLUMN);
            }

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

            }
        });
    } else {
        spinner.setVisibility(View.GONE);
    }

}