Search in sources :

Example 96 with Spinner

use of android.widget.Spinner in project fresco by facebook.

the class MainActivity method setupViews.

public void setupViews() {
    mImageView = (ImageView) findViewById(R.id.image);
    mValidityTextView = (TextView) findViewById(R.id.validity);
    Spinner spinner = (Spinner) findViewById(R.id.spinner);
    ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.image_options, android.R.layout.simple_spinner_item);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinner.setAdapter(adapter);
    spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            // Cropping the central half of the image for testing
            int startX = mOriginalWidth / 4;
            int startY = mOriginalHeight / 4;
            int width = mOriginalWidth / 2;
            int height = mOriginalHeight / 2;
            switch(position) {
                case BASIC_LOAD:
                    loadBasicBitmap();
                    break;
                case CROPPED_LOAD:
                    loadCroppedBitmap(startX, startY, width, height);
                    break;
                case TRANSLATED_LOAD:
                    loadTranslatedBitmap(startX, startY, width, height, startX, startY);
                    break;
                case TRANSFORMED_LOAD:
                    loadTransformedBitmap(startX, startY, width, height, getMatrix(0, 0, 0.5f, 0.5f, 60.0f));
                    break;
                case SCALED_LOAD:
                    loadScaledBitmap(width, height);
                    break;
                case COLOR_ARRAY_LOAD:
                    loadFromColorArray();
                    break;
                case CROPPED_COLOR_ARRAY_LOAD:
                    loadFromCroppedColorArray(startX, startY, width, height);
                    break;
                case RESOURCE_LOAD:
                default:
                    loadFromResources();
            }
        }

        @Override
        public void onNothingSelected(AdapterView<?> adapterView) {
        }
    });
}
Also used : Spinner(android.widget.Spinner) AdapterView(android.widget.AdapterView) ImageView(android.widget.ImageView) TextView(android.widget.TextView) View(android.view.View) AdapterView(android.widget.AdapterView)

Example 97 with Spinner

use of android.widget.Spinner in project rebound by facebook.

the class SpringConfiguratorView method generateHierarchy.

/**
   * Programmatically build up the view hierarchy to avoid the need for resources.
   * @return View hierarchy
   */
private View generateHierarchy(Context context) {
    Resources resources = getResources();
    FrameLayout.LayoutParams params;
    int fivePx = dpToPx(5, resources);
    int tenPx = dpToPx(10, resources);
    int twentyPx = dpToPx(20, resources);
    TableLayout.LayoutParams tableLayoutParams = new TableLayout.LayoutParams(0, ViewGroup.LayoutParams.WRAP_CONTENT, 1f);
    tableLayoutParams.setMargins(0, 0, fivePx, 0);
    LinearLayout seekWrapper;
    FrameLayout root = new FrameLayout(context);
    params = createLayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, dpToPx(300, resources));
    root.setLayoutParams(params);
    FrameLayout container = new FrameLayout(context);
    params = createMatchParams();
    params.setMargins(0, twentyPx, 0, 0);
    container.setLayoutParams(params);
    container.setBackgroundColor(Color.argb(100, 0, 0, 0));
    root.addView(container);
    mSpringSelectorSpinner = new Spinner(context, Spinner.MODE_DIALOG);
    params = createMatchWrapParams();
    params.gravity = Gravity.TOP;
    params.setMargins(tenPx, tenPx, tenPx, 0);
    mSpringSelectorSpinner.setLayoutParams(params);
    container.addView(mSpringSelectorSpinner);
    LinearLayout linearLayout = new LinearLayout(context);
    params = createMatchWrapParams();
    params.setMargins(0, 0, 0, dpToPx(80, resources));
    params.gravity = Gravity.BOTTOM;
    linearLayout.setLayoutParams(params);
    linearLayout.setOrientation(LinearLayout.VERTICAL);
    container.addView(linearLayout);
    seekWrapper = new LinearLayout(context);
    params = createMatchWrapParams();
    params.setMargins(tenPx, tenPx, tenPx, twentyPx);
    seekWrapper.setPadding(tenPx, tenPx, tenPx, tenPx);
    seekWrapper.setLayoutParams(params);
    seekWrapper.setOrientation(LinearLayout.HORIZONTAL);
    linearLayout.addView(seekWrapper);
    mTensionSeekBar = new SeekBar(context);
    mTensionSeekBar.setLayoutParams(tableLayoutParams);
    seekWrapper.addView(mTensionSeekBar);
    mTensionLabel = new TextView(getContext());
    mTensionLabel.setTextColor(mTextColor);
    params = createLayoutParams(dpToPx(50, resources), ViewGroup.LayoutParams.MATCH_PARENT);
    mTensionLabel.setGravity(Gravity.CENTER_VERTICAL | Gravity.LEFT);
    mTensionLabel.setLayoutParams(params);
    mTensionLabel.setMaxLines(1);
    seekWrapper.addView(mTensionLabel);
    seekWrapper = new LinearLayout(context);
    params = createMatchWrapParams();
    params.setMargins(tenPx, tenPx, tenPx, twentyPx);
    seekWrapper.setPadding(tenPx, tenPx, tenPx, tenPx);
    seekWrapper.setLayoutParams(params);
    seekWrapper.setOrientation(LinearLayout.HORIZONTAL);
    linearLayout.addView(seekWrapper);
    mFrictionSeekBar = new SeekBar(context);
    mFrictionSeekBar.setLayoutParams(tableLayoutParams);
    seekWrapper.addView(mFrictionSeekBar);
    mFrictionLabel = new TextView(getContext());
    mFrictionLabel.setTextColor(mTextColor);
    params = createLayoutParams(dpToPx(50, resources), ViewGroup.LayoutParams.MATCH_PARENT);
    mFrictionLabel.setGravity(Gravity.CENTER_VERTICAL | Gravity.LEFT);
    mFrictionLabel.setLayoutParams(params);
    mFrictionLabel.setMaxLines(1);
    seekWrapper.addView(mFrictionLabel);
    View nub = new View(context);
    params = createLayoutParams(dpToPx(60, resources), dpToPx(40, resources));
    params.gravity = Gravity.TOP | Gravity.CENTER;
    nub.setLayoutParams(params);
    nub.setOnTouchListener(new OnNubTouchListener());
    nub.setBackgroundColor(Color.argb(255, 0, 164, 209));
    root.addView(nub);
    return root;
}
Also used : SeekBar(android.widget.SeekBar) Spinner(android.widget.Spinner) View(android.view.View) AdapterView(android.widget.AdapterView) AbsListView(android.widget.AbsListView) TextView(android.widget.TextView) FrameLayout(android.widget.FrameLayout) TextView(android.widget.TextView) Resources(android.content.res.Resources) TableLayout(android.widget.TableLayout) LinearLayout(android.widget.LinearLayout)

Example 98 with Spinner

use of android.widget.Spinner in project WilliamChart by diogobernardino.

the class MainActivity method onCreateOptionsMenu.

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.menu, menu);
    MenuItem item = menu.findItem(R.id.spinner);
    Spinner spinner = (Spinner) MenuItemCompat.getActionView(item);
    spinner.setAdapter(mAdapter);
    spinner.setSelection(currSpinnerSelection);
    spinner.setOnItemSelectedListener(this);
    return super.onCreateOptionsMenu(menu);
}
Also used : Spinner(android.widget.Spinner) MenuItem(android.view.MenuItem)

Example 99 with Spinner

use of android.widget.Spinner in project FlexibleAdapter by davideas.

the class FragmentAnimators method initializeSpinnerItemAnimators.

private void initializeSpinnerItemAnimators() {
    // Creating adapter for spinner1
    ArrayAdapter<AnimatorType> spinnerAdapter = new ArrayAdapter<AnimatorType>(getActivity(), android.R.layout.simple_spinner_item, AnimatorType.values()) {

        @Override
        public View getDropDownView(int position, View convertView, ViewGroup parent) {
            View view = super.getDropDownView(position, convertView, parent);
            view.setBackgroundResource(R.drawable.selector_item_light);
            view.setActivated(position == selectedItemAnimator);
            return view;
        }
    };
    // Drop down layout style - list view with radio button
    spinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    // Make visible spinner configuration
    getActivity().findViewById(R.id.layout_for_spinners).setVisibility(View.VISIBLE);
    Spinner spinner = (Spinner) getActivity().findViewById(R.id.spinner_item_animators);
    spinner.setAdapter(spinnerAdapter);
    spinner.setSelection(7);
    spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            mRecyclerView.setItemAnimator(AnimatorType.values()[position].getAnimator());
            mRecyclerView.getItemAnimator().setAddDuration(500);
            mRecyclerView.getItemAnimator().setRemoveDuration(500);
            selectedItemAnimator = position;
        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {
        }
    });
}
Also used : ViewGroup(android.view.ViewGroup) Spinner(android.widget.Spinner) AdapterView(android.widget.AdapterView) View(android.view.View) AdapterView(android.widget.AdapterView) FlipView(eu.davidea.flipview.FlipView) RecyclerView(android.support.v7.widget.RecyclerView) ArrayAdapter(android.widget.ArrayAdapter)

Example 100 with Spinner

use of android.widget.Spinner in project FlexibleAdapter by davideas.

the class FragmentAnimators method initializeSpinnerScrollAnimators.

private void initializeSpinnerScrollAnimators() {
    // Creating adapter for spinner2
    ArrayAdapter<ScrollAnimatorType> spinnerAdapter = new ArrayAdapter<ScrollAnimatorType>(getActivity(), android.R.layout.simple_spinner_item, ScrollAnimatorType.values()) {

        @Override
        public View getDropDownView(int position, View convertView, ViewGroup parent) {
            View view = super.getDropDownView(position, convertView, parent);
            view.setBackgroundResource(R.drawable.selector_item_light);
            view.setActivated(position == selectedScrollAnimator);
            return view;
        }
    };
    // Drop down layout style - list view with radio button
    spinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    // Make visible spinner configuration
    getActivity().findViewById(R.id.layout_for_spinners).setVisibility(View.VISIBLE);
    Spinner spinner = (Spinner) getActivity().findViewById(R.id.spinner_scrolling_animation);
    spinner.setAdapter(spinnerAdapter);
    spinner.setSelection(3);
    spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            DatabaseConfiguration.scrollAnimatorType = ScrollAnimatorType.values()[position];
            selectedScrollAnimator = position;
        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {
        }
    });
}
Also used : ViewGroup(android.view.ViewGroup) Spinner(android.widget.Spinner) AdapterView(android.widget.AdapterView) View(android.view.View) AdapterView(android.widget.AdapterView) FlipView(eu.davidea.flipview.FlipView) RecyclerView(android.support.v7.widget.RecyclerView) ArrayAdapter(android.widget.ArrayAdapter)

Aggregations

Spinner (android.widget.Spinner)160 View (android.view.View)70 AdapterView (android.widget.AdapterView)58 TextView (android.widget.TextView)51 ArrayAdapter (android.widget.ArrayAdapter)50 LinearLayout (android.widget.LinearLayout)29 EditText (android.widget.EditText)20 Intent (android.content.Intent)19 Button (android.widget.Button)19 RecyclerView (android.support.v7.widget.RecyclerView)18 CompoundButton (android.widget.CompoundButton)16 ViewGroup (android.view.ViewGroup)13 ImageView (android.widget.ImageView)13 DialogInterface (android.content.DialogInterface)12 CheckBox (android.widget.CheckBox)11 ListView (android.widget.ListView)11 ArrayList (java.util.ArrayList)11 AutoCompleteTextView (android.widget.AutoCompleteTextView)9 AlertDialog (android.app.AlertDialog)7 LayoutInflater (android.view.LayoutInflater)7