Example usage for android.widget ArrayAdapter setDropDownViewResource

List of usage examples for android.widget ArrayAdapter setDropDownViewResource

Introduction

In this page you can find the example usage for android.widget ArrayAdapter setDropDownViewResource.

Prototype

public void setDropDownViewResource(@LayoutRes int resource) 

Source Link

Document

Sets the layout resource to create the drop down views.

Usage

From source file:com.kubotaku.android.code4kyoto5374.fragments.HomeSelectFragment.java

private void showPlaceSelector(RealmResults<AreaDays> areaDaysResult) {

    final TextView textAlert = (TextView) getView().findViewById(R.id.text_place_alert);
    final Spinner spinner = (Spinner) getView().findViewById(R.id.spinner_select_town);

    if (areaDaysResult.size() <= 1) {
        textAlert.setVisibility(View.GONE);
        spinner.setVisibility(View.GONE);

        if (areaDaysResult.size() == 1) {
            showValidSelectedAreaDays(areaDaysResult.first());
        }/*w  ww  . j  a  v a2s .com*/

    } else {
        textAlert.setVisibility(View.VISIBLE);
        spinner.setVisibility(View.VISIBLE);

        ArrayAdapter<String> adapter = new ArrayAdapter<String>(getContext(),
                android.R.layout.simple_spinner_item);
        adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

        for (AreaDays areaDays : areaDaysResult) {
            adapter.add(areaDays.areaName);
        }
        spinner.setAdapter(adapter);
        spinner.setOnItemSelectedListener(onTownSelectedListener);
    }
}

From source file:net.dian1.player.activity.RadioActivity.java

/** Called when the activity is first created. */
@Override/*from   w ww  .  jav a 2  s  .  c o  m*/
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.search);

    mRadioListView = (ListView) findViewById(R.id.SearchListView);
    mRadioAdapter = new RadioAdapter(this);
    mRadioListView.setAdapter(mRadioAdapter);
    mRadioListView.setOnItemClickListener(mRadioListListener);
    mButton = (Button) findViewById(R.id.SearchButton);
    mButton.setText(R.string.radio);
    mButton.setOnClickListener(mButtonClickListener);
    mEditText = (EditText) findViewById(R.id.SearchEditText);
    mViewFlipper = (ViewFlipper) findViewById(R.id.SearchViewFlipper);

    mSpinner = (Spinner) findViewById(R.id.SearchSpinner);
    ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.radio_modes,
            android.R.layout.simple_spinner_item);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    mSpinner.setAdapter(adapter);
    mEditText.setHint(R.string.radio_hint);

    mRadioLoadingDialog = new RadioLoadingDialog(this, R.string.loading_recomended_radios,
            R.string.failed_recomended_radios);

    mRadioLoadingDialog.execute();

    mSpinner.setOnItemSelectedListener(new OnItemSelectedListener() {

        @Override
        public void onItemSelected(AdapterView<?> arg0, View arg1, int position, long arg3) {
            switch (position) {
            case 0:
                // recent
                mRadioAdapter.setList(new DatabaseImpl(RadioActivity.this).getRecentRadios(20));
                break;
            case 1:
                // recommended
                switch (mRadioLoadingDialog.getStatus()) {
                case RUNNING:
                    break;
                case FINISHED:
                    mRadioLoadingDialog = new RadioLoadingDialog(RadioActivity.this,
                            R.string.loading_recomended_radios, R.string.failed_recomended_radios);
                    mRadioLoadingDialog.execute();
                    break;
                case PENDING:
                    mRadioLoadingDialog.execute();
                    break;
                }
                break;

            default:
                break;
            }

            setupListView();
        }

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

    });

    // TODO (maybe) if recent.count > 0 set to recent
    mSpinner.setSelection(1);

    mGestureOverlayView = (GestureOverlayView) findViewById(R.id.gestures);
    mGestureOverlayView.addOnGesturePerformedListener(Dian1Application.getInstance().getPlayerGestureHandler());
}

From source file:com.microsoft.aad.adal.example.userappwithbroker.AcquireTokenFragment.java

void bindSpinnerChoice(final Spinner spinner, final Class<? extends Enum> spinnerChoiceClass) {
    final ArrayAdapter<String> adapter = new ArrayAdapter<>(getContext(), android.R.layout.simple_spinner_item,
            new ArrayList<String>() {
                {//w  w w.  ja  v a 2s  .c o m
                    for (Enum choice : spinnerChoiceClass.getEnumConstants())
                        add(choice.name());
                }
            });

    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinner.setAdapter(adapter);
}

From source file:com.forrestguice.suntimeswidget.TimeDateDialog.java

/**
 * @param context a context used to access resources
 * @param dialogContent an inflated layout containing the dialog's other views
 *//*w  ww  .  j a  v  a  2s. co  m*/
private void initViews(Context context, View dialogContent) {
    ArrayAdapter<WidgetSettings.DateMode> spinner_dateModeAdapter;
    spinner_dateModeAdapter = new ArrayAdapter<WidgetSettings.DateMode>(context,
            R.layout.layout_listitem_oneline, WidgetSettings.DateMode.values());
    spinner_dateModeAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

    spinner_dateMode = (Spinner) dialogContent.findViewById(R.id.appwidget_date_mode);
    spinner_dateMode.setAdapter(spinner_dateModeAdapter);
    spinner_dateMode.setOnItemSelectedListener(dateModeSelectedListener);

    picker = (DatePicker) dialogContent.findViewById(R.id.appwidget_date_custom);

    scroll = (ScrollView) dialogContent.findViewById(R.id.appwidget_date_scroll);
    scroll.scrollTo(0, 0);
}

From source file:cc.siara.csv_ml_demo.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);

    // Set event handlers
    setContentView(R.layout.activity_main);
    Button btnXML = (Button) findViewById(R.id.btnXML);
    btnXML.setOnClickListener(this);
    Button btnJSON = (Button) findViewById(R.id.btnJSON);
    btnJSON.setOnClickListener(this);
    Button btnXPath = (Button) findViewById(R.id.btnXPath);
    btnXPath.setOnClickListener(this);
    Button btnDDLDML = (Button) findViewById(R.id.btnDDLDML);
    btnDDLDML.setOnClickListener(this);
    Button btnXMLtoCSV = (Button) findViewById(R.id.btnXMLtoCSV);
    btnXMLtoCSV.setOnClickListener(this);
    Spinner spinner = (Spinner) findViewById(R.id.spExamples);
    spinner.setOnItemSelectedListener(this);
    ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.input_examples,
            android.R.layout.simple_spinner_item);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinner.setAdapter(adapter);//from www .j a  v a2  s .  c  o m

}

From source file:co.carlosandresjimenez.android.gotit.RegistrationFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_registration, container, false);
    ButterKnife.bind(this, rootView);

    mGoogleConnection = GoogleConnection.getInstance(getActivity());
    String userEmail = mGoogleConnection.getAccountName();
    if (userEmail != null && !userEmail.isEmpty())
        mTvEmail.setText(userEmail);//from  w w w .  j a  va  2  s  .com
    else
        Log.e(LOG_TAG, "Cannot get user's email address");

    Person person = mGoogleConnection.getCurrentPerson();
    if (person != null) {
        if (person.hasName()) {
            mTvUserName.setText(person.getName().getGivenName());
            mTvUserLastname.setText(person.getName().getFamilyName());
        }

        if (person.hasBirthday())
            mTvUserBirthdate.setText(person.getBirthday());

        if (person.hasImage())
            mUserAvatarUrl = person.getImage().getUrl();
    }

    AppCompatActivity activity = (AppCompatActivity) getActivity();
    if (null != mToolbar) {
        activity.setSupportActionBar(mToolbar);
        ActionBar actionBar = activity.getSupportActionBar();
        actionBar.setHomeAsUpIndicator(R.drawable.ic_clear_white_24dp);
        //activity.getSupportActionBar().setIcon(R.drawable.ic_clear_white_24dp);
        actionBar.setDisplayHomeAsUpEnabled(true);
        actionBar.setHomeButtonEnabled(true);
    }

    // Create an ArrayAdapter using the string array and a default spinner layout
    ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(getActivity(),
            R.array.user_types_labels, R.layout.spinner_item);
    // Specify the layout to use when the list of choices appears
    adapter.setDropDownViewResource(R.layout.spinner_dropdown_item);
    // Apply the adapter to the spinner
    mSpUserType.setAdapter(adapter);

    return rootView;
}

From source file:com.ze.client.projecto.activity.MainActivity.java

@Override
public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
    final int size = data.getCount();
    boolean wasEmpty = mList.isEmpty();
    mList.clear();/*w  ww  .j  a  va 2 s .  c  o  m*/
    for (int i = 0; i < size; i++) {
        data.moveToNext();
        mList.add(ProjectorDbHelper.createProjectorFromCursor(this, data));
    }
    if (mList.size() > 0) {
        ArrayAdapter<Projector> adapter = new ArrayAdapter<>(this, R.layout.dropdown_projector, mList);
        adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        if (mProjectorsSpinner != null) {
            mProjectorsSpinner.setAdapter(adapter);
            mProjectorsSpinner.setVisibility(View.VISIBLE);
            mProjectorsSpinnerCaption.setVisibility(View.VISIBLE);
        }
        if (!wasEmpty)
            refreshGui(F_OFF, F_OFF);
    } else {
        mProjectorsSpinner.setVisibility(View.GONE);
        mProjectorsSpinnerCaption.setVisibility(View.GONE);
    }
}

From source file:com.example.android.popularmovies.app.MovieListingFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    movies = new ArrayList<MovieDetails>();

    movieAdapter = new MovieArrayAdapter(getActivity(), // The current context (this activity)
            R.layout.list_item_listing, // The name of the layout ID.
            R.id.list_item_listing_textview, // The ID of the textview to populate.
            movies);/*w w w  .  j  a  v  a 2 s  . c o  m*/

    View rootView = inflater.inflate(R.layout.fragment_main, container, false);

    Spinner spinner = (Spinner) rootView.findViewById(R.id.sort_spinner);
    // Create an ArrayAdapter using the string array and a default spinner layout
    ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(getActivity(), R.array.sort_options,
            android.R.layout.simple_spinner_item);
    // Specify the layout to use when the list of choices appears
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    // Apply the adapter to the spinner
    spinner.setAdapter(adapter);

    FetchMovieListingTask movieListingTask = new FetchMovieListingTask();
    movieListingTask.execute(String.valueOf(spinner.getSelectedItemPosition()));

    spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
            FetchMovieListingTask movieListingTask = new FetchMovieListingTask();
            movieListingTask.execute(String.valueOf(i));
        }

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

        }
    });

    // Get a reference to the ListView, and attach this adapter to it.
    GridView gridView = (GridView) rootView.findViewById(R.id.grid_view_listing);
    gridView.setAdapter(movieAdapter);
    gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
            // Log.i("MovieListingFragment", "Item clicked: " + view.toString() + " " + i + " " + l);
            getActivity().getSupportFragmentManager().beginTransaction().addToBackStack(null)
                    .replace(R.id.container, MovieDetailsFragment.newInstance(movies.get(i).id))
                    .setTransition(FragmentTransaction.TRANSIT_FRAGMENT_CLOSE).commit();
        }
    });

    return rootView;
}

From source file:com.creationgroundmedia.popularmovies.MovieListActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.menu_main, menu);
    inflater.inflate(R.menu.menu_fragment, menu);
    /**/* ww  w . ja  v  a  2s.com*/
     * use a spinner to select sort order, that way the user can always see what the order is
     */
    MenuItem item = menu.findItem(R.id.action_sorting_spinner);
    Spinner sortingSpinner = (Spinner) MenuItemCompat.getActionView(item);
    ArrayAdapter<CharSequence> spinnerAdapter = ArrayAdapter.createFromResource(this, R.array.sorting_modes,
            R.layout.spinner_item);
    spinnerAdapter.setDropDownViewResource(R.layout.spinner_item);
    sortingSpinner.setAdapter(spinnerAdapter);
    sortingSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            sortOrder = sortOrders[position];
            movieCursorLoader = getSupportLoaderManager().restartLoader(URL_LOADER, null,
                    MovieListActivity.this);
            recyclerView.getAdapter().notifyDataSetChanged();
        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {
        }
    });

    item = menu.findItem(R.id.action_faves_only);
    Button faveButton = (Button) MenuItemCompat.getActionView(item);
    faveButton.setSelected(mFavoritesOnly);
    faveButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            mFavoritesOnly = !v.isSelected();
            v.setSelected(mFavoritesOnly);
            mSelectFavorites = mFavoritesOnly ? MoviesContract.MovieEntry.COLUMN_FAVORITE + " = 1" : null;
            movieCursorLoader = getSupportLoaderManager().restartLoader(URL_LOADER, null,
                    MovieListActivity.this);
        }
    });

    return super.onCreateOptionsMenu(menu);
}

From source file:com.justplay1.shoppist.features.lists.items.add.AddListItemFragment.java

private void initializePriorityList() {
    String[] data = getResources().getStringArray(R.array.priority);
    ArrayAdapter<String> adapter = new ArrayAdapter<>(getContext(), android.R.layout.simple_spinner_item, data);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    priorityList.setAdapter(adapter);// w ww . ja  va 2s .c  o  m
    priorityList.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            mPresenter.setPriority(position);
        }

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

        }
    });
}