Example usage for android.widget Spinner setAdapter

List of usage examples for android.widget Spinner setAdapter

Introduction

In this page you can find the example usage for android.widget Spinner setAdapter.

Prototype

@Override
public void setAdapter(SpinnerAdapter adapter) 

Source Link

Document

Sets the SpinnerAdapter used to provide the data which backs this Spinner.

Usage

From source file:me.diskstation.ammon.gpsrunner.ui.LineDetailsFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    View view = inflater.inflate(R.layout.fragment_line_details, container, false);
    lineChart = (LineChart) view.findViewById(R.id.runLineChart);
    setUpChart(lineChart);/*w  ww .  j  av a2  s  .  co  m*/
    Spinner modeSpinner = (Spinner) view.findViewById(R.id.modeSpinner);
    //Adding modes via adapter
    ArrayAdapter<CharSequence> modeAdapter = ArrayAdapter.createFromResource(getActivity(),
            R.array.detail_modes_array, R.layout.spinner_item);
    modeAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    modeSpinner.setAdapter(modeAdapter);
    modeSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            mode = position;
            setUpChart(lineChart);
        }

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

        }
    });
    return view;
}

From source file:org.catrobat.catroid.content.bricks.BroadcastBrick.java

@Override
public View getView(final Context context, int brickId, BaseAdapter baseAdapter) {
    if (animationState) {
        return view;
    }//from  w  w  w .  j ava  2s  .  com
    if (view == null) {
        alphaValue = 255;
    }
    view = View.inflate(context, R.layout.brick_broadcast, null);
    view = getViewWithAlpha(alphaValue);
    setCheckboxView(R.id.brick_broadcast_checkbox);

    checkbox.setOnCheckedChangeListener(new OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            checked = isChecked;
            adapter.handleCheck(BroadcastBrick.this, isChecked);
        }
    });

    final Spinner broadcastSpinner = (Spinner) view.findViewById(R.id.brick_broadcast_spinner);
    broadcastSpinner.setFocusableInTouchMode(false);
    broadcastSpinner.setFocusable(false);
    if (!(checkbox.getVisibility() == View.VISIBLE)) {
        broadcastSpinner.setClickable(true);
        broadcastSpinner.setEnabled(true);
    } else {
        broadcastSpinner.setClickable(false);
        broadcastSpinner.setEnabled(false);
    }

    broadcastSpinner.setAdapter(MessageContainer.getMessageAdapter(context));
    broadcastSpinner.setOnItemSelectedListener(new OnItemSelectedListener() {

        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            String selectedMessage = broadcastSpinner.getSelectedItem().toString();
            if (selectedMessage.equals(context.getString(R.string.new_broadcast_message))) {
                showNewMessageDialog(broadcastSpinner);
            } else {
                broadcastMessage = selectedMessage;
                adapterView = parent;
            }
        }

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

    setSpinnerSelection(broadcastSpinner);
    return view;
}

From source file:com.RSMSA.policeApp.Dialogues.PaymentConfirmationDialogue.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    getDialog().requestWindowFeature(Window.FEATURE_NO_TITLE);
    getDialog().setCanceledOnTouchOutside(false);

    RelativeLayout relativeLayout = (RelativeLayout) inflater.inflate(R.layout.dialogue_payment_confirmation,
            container, false);//from  w w  w  .ja  va2s . co m

    TextView costTextView = (TextView) relativeLayout.findViewById(R.id.place);
    costTextView.setText(cost + "");

    TextView nameTextView = (TextView) relativeLayout.findViewById(R.id.name);
    nameTextView.setText(name);

    TextView licenceNumberTextView = (TextView) relativeLayout.findViewById(R.id.licence_number);
    licenceNumberTextView.setText(offence.getDriver_license_number() + "");

    TextView plate_numberTextView = (TextView) relativeLayout.findViewById(R.id.plate_number);
    plate_numberTextView.setText(offence.getVehicle_plate_number());

    final String[] paymentMethodsArray = this.getResources().getStringArray(R.array.payment_methods);
    Spinner paymentMethodSpinner = (Spinner) relativeLayout.findViewById(R.id.payment_method_spinner);
    PaymentMethodSpinnerAdapter adapter = new PaymentMethodSpinnerAdapter(getActivity(), R.layout.row_menu,
            paymentMethodsArray);
    paymentMethodSpinner.setAdapter(adapter);
    paymentMethodSpinner.setBackground(null);
    paymentMethodSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            paymentMethod = paymentMethodsArray[position];
        }

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

        }
    });
    receiptEditText = (EditText) relativeLayout.findViewById(R.id.receipt);

    TextView okButton = (TextView) relativeLayout.findViewById(R.id.ok_button);
    okButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (receiptEditText.getText().toString().equals("")) {
                receiptEditText.setHintTextColor(Color.RED);
            } else {
                new ProcessRegister().execute();
            }
        }
    });

    TextView cancelButton = (TextView) relativeLayout.findViewById(R.id.cancel_button);
    cancelButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            //mListener.onComplete(false, index);
            dismiss();
        }
    });

    return relativeLayout;
}

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 source file:com.google.android.apps.flexbox.MainActivity.java

private void initializeSpinner(int currentValue, int menuItemId, Menu navigationMenu, int arrayResourceId,
        AdapterView.OnItemSelectedListener listener, ValueToStringConverter converter) {
    Spinner spinner = (Spinner) MenuItemCompat.getActionView(navigationMenu.findItem(menuItemId));
    ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, arrayResourceId,
            R.layout.spinner_item);//  w ww.  j  a v a  2  s.c  o m
    spinner.setAdapter(adapter);
    spinner.setOnItemSelectedListener(listener);
    String selectedAsString = converter.asString(currentValue);
    int position = adapter.getPosition(selectedAsString);
    spinner.setSelection(position);
}

From source file:ca.liquidlabs.android.speedtestvisualizer.activities.MapperActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // get feature to show progress in actionbar when processing data
    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
    setContentView(R.layout.activity_mapper);
    // It seems like 4.0.x enables progress by default - STOP it!
    hideProgressIndicator();//w w w  . j  av a2 s . c om

    Spinner spinner = (Spinner) findViewById(R.id.spinner_conntype_filter);
    ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.filters_array,
            android.R.layout.simple_spinner_item);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinner.setAdapter(adapter);
    spinner.setOnItemSelectedListener(new ConnectionTypeFilterHandler());

    // Show the Up button in the action bar.
    setupActionBar();

    setUpMapIfNeeded();
}

From source file:com.synchophy.ui.CoverFlowActivity.java

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

    setContentView(R.layout.coverflow);//from  www  .  ja  va 2  s.  co  m

    Spinner browseSpinner = (Spinner) this.findViewById(R.id.browseSpinner);
    ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item,
            new String[] { "Covers", "Albums", "Artists" });
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    browseSpinner.setAdapter(adapter);

    ActivitySwipeDetector activitySwipeDetector = new ActivitySwipeDetector(this) {
        @Override
        public void onLeftToRightSwipe() {
            CoverFlowActivity.this.finish();
            overridePendingTransition(R.anim.hold, R.anim.push_out_to_right);
        }

        @Override
        public void onBottomToTopSwipe() {
            showPlaylist();
        }

    };

    LinearLayout lowestLayout = (LinearLayout) this.findViewById(R.id.coverflowBack);
    lowestLayout.setOnTouchListener(activitySwipeDetector);

    coverFlow = (CoverFlow) findViewById(R.id.coverflow);
    coverFlow.setSpacing(-25);
    coverFlow.setSelection(4, true);
    coverFlow.setAnimationDuration(1000);
    registerForContextMenu(coverFlow);

    ImageAdapter coverImageAdapter = new ImageAdapter(CoverFlowActivity.this);
    coverFlow.setAdapter(coverImageAdapter);

    refresh();
}

From source file:com.example.linhdq.test.documents.creation.visualisation.LayoutQuestionDialog.java

@NonNull
@Override/*from   ww w .jav  a  2  s.c o  m*/
public Dialog onCreateDialog(Bundle savedInstanceState) {
    final Context context = getContext();
    mLayout = null;
    Pair<String, String> language = PreferencesUtils.getOCRLanguage(context);

    final InstallStatus installStatus = OcrLanguageDataStore.isLanguageInstalled(language.first, context);

    if (!installStatus.isInstalled()) {
        final String defaultLanguage = context.getString(R.string.default_ocr_language);
        final String defaultLanguageDisplay = context.getString(R.string.default_ocr_display_language);
        language = Pair.create(defaultLanguage, defaultLanguageDisplay);
    }
    mLanguage = language.first;

    AlertDialog.Builder builder;

    builder = new AlertDialog.Builder(context);
    builder.setCancelable(false);
    View layout = View.inflate(context, R.layout.dialog_layout_question, null);
    builder.setView(layout);

    final ViewFlipper titleViewFlipper = (ViewFlipper) layout.findViewById(R.id.layout_title);
    final ImageView columnLayout = (ImageView) layout.findViewById(R.id.column_layout);
    final ImageView pageLayout = (ImageView) layout.findViewById(R.id.page_layout);
    final ImageSwitcher fairy = (ImageSwitcher) layout.findViewById(R.id.fairy_layout);
    fairy.setFactory(new ViewSwitcher.ViewFactory() {
        public View makeView() {
            return new ImageView(context);
        }
    });
    fairy.setImageResource(R.drawable.fairy_looks_center);
    fairy.setInAnimation(context, android.R.anim.fade_in);
    fairy.setOutAnimation(context, android.R.anim.fade_out);

    final int color = context.getResources().getColor(R.color.progress_color);

    final PorterDuffColorFilter colorFilter = new PorterDuffColorFilter(color, PorterDuff.Mode.LIGHTEN);

    columnLayout.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (mLayout != LayoutKind.COMPLEX) {
                fairy.setImageResource(R.drawable.fairy_looks_left);
                titleViewFlipper.setDisplayedChild(2);
                columnLayout.setColorFilter(colorFilter);
                pageLayout.clearColorFilter();
                mLayout = LayoutKind.COMPLEX;
            }

        }
    });
    pageLayout.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (mLayout != LayoutKind.SIMPLE) {
                mLayout = LayoutKind.SIMPLE;
                titleViewFlipper.setDisplayedChild(1);
                fairy.setImageResource(R.drawable.fairy_looks_right);
                pageLayout.setColorFilter(colorFilter);
                columnLayout.clearColorFilter();
            }
        }
    });

    final Spinner langButton = (Spinner) layout.findViewById(R.id.button_language);
    List<OcrLanguage> installedLanguages = OcrLanguageDataStore.getInstalledOCRLanguages(context);

    // actual values uses by tesseract
    final ArrayAdapter<OcrLanguage> adapter = new ArrayAdapter<>(context, R.layout.item_spinner_language,
            installedLanguages);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    langButton.setAdapter(adapter);
    for (int i = 0; i < installedLanguages.size(); i++) {
        OcrLanguage lang = installedLanguages.get(i);
        if (lang.getValue().equals(language.first)) {
            langButton.setSelection(i, false);
            break;
        }
    }
    langButton.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            final OcrLanguage item = adapter.getItem(position);
            mLanguage = item.getValue();
            PreferencesUtils.saveOCRLanguage(context, item);
        }

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

        }
    });

    builder.setPositiveButton(R.string.start_scan, new DialogInterface.OnClickListener() {

        public void onClick(DialogInterface dialog, int id) {
            if (mLayout == null) {
                mLayout = LayoutKind.SIMPLE;
            }
            LayoutChoseListener listener = (LayoutChoseListener) getActivity();
            listener.onLayoutChosen(mLayout, mLanguage);
            dialog.dismiss();
        }
    });

    builder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {

        public void onClick(DialogInterface dialog, int id) {
            getActivity().finish();
            dialog.dismiss();
        }
    });

    return builder.create();

}

From source file:freed.viewer.stack.StackActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.stack_activity);
    Spinner stackvaluesButton = (Spinner) findViewById(R.id.freedviewer_stack_stackvalues_button);
    imageView = (TouchImageView) findViewById(R.id.freedviewer_stack_imageview);
    String[] items = new String[] { AVARAGE, AVARAGE1x2, AVARAGE1x3, AVARAGE3x3, LIGHTEN, LIGHTEN_V, MEDIAN,
            EXPOSURE };//from ww w .  j  ava 2 s  . c o m
    ArrayAdapter<String> stackadapter = new ArrayAdapter<>(getContext(), android.R.layout.simple_spinner_item,
            items);
    stackvaluesButton.setAdapter(stackadapter);
    filesToStack = getIntent().getStringArrayExtra(DngConvertingFragment.EXTRA_FILESTOCONVERT);
    renderScriptHandler = new RenderScriptHandler(getContext());

    stackvaluesButton.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            stackMode = position;
        }

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

        }
    });

    Button buttonStartStack = (Button) findViewById(R.id.button_stackPics);
    buttonStartStack.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            processStack();
        }
    });

    closeButton = (Button) findViewById(R.id.button_stack_close);
    closeButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Intent returnIntent = new Intent();
            setResult(Activity.RESULT_CANCELED, returnIntent);
            finish();
        }
    });
    stackcounter = (TextView) findViewById(R.id.textView_stack_count);
    updateCounter(0);
}

From source file:com.google.android.apps.flexbox.FlexItemEditFragment.java

@Nullable
@Override/*from   ww w.  j ava2s . c o m*/
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
        @Nullable Bundle savedInstanceState) {
    final View view = inflater.inflate(R.layout.fragment_flex_item_edit, container, false);
    getDialog().setTitle(String.valueOf(mFlexItem.index + 1));

    final TextInputLayout orderTextInput = (TextInputLayout) view.findViewById(R.id.input_layout_order);
    EditText orderEdit = (EditText) view.findViewById(R.id.edit_text_order);
    orderEdit.setText(String.valueOf(mFlexItem.order));
    orderEdit.addTextChangedListener(
            new FlexEditTextWatcher(orderTextInput, new IntegerInputValidator(), R.string.must_be_integer));

    final TextInputLayout flexGrowInput = (TextInputLayout) view.findViewById(R.id.input_layout_flex_grow);
    final EditText flexGrowEdit = (EditText) view.findViewById(R.id.edit_text_flex_grow);
    flexGrowEdit.setText(String.valueOf(mFlexItem.flexGrow));
    flexGrowEdit.addTextChangedListener(new FlexEditTextWatcher(flexGrowInput,
            new NonNegativeDecimalInputValidator(), R.string.must_be_non_negative_float));

    final TextInputLayout flexShrinkInput = (TextInputLayout) view.findViewById(R.id.input_layout_flex_shrink);
    EditText flexShrinkEdit = (EditText) view.findViewById(R.id.edit_text_flex_shrink);
    flexShrinkEdit.setText(String.valueOf(mFlexItem.flexShrink));
    flexShrinkEdit.addTextChangedListener(new FlexEditTextWatcher(flexShrinkInput,
            new NonNegativeDecimalInputValidator(), R.string.must_be_non_negative_float));

    final TextInputLayout flexBasisPercentInput = (TextInputLayout) view
            .findViewById(R.id.input_layout_flex_basis_percent);
    EditText flexBasisPercentEdit = (EditText) view.findViewById(R.id.edit_text_flex_basis_percent);
    if (mFlexItem.flexBasisPercent != FlexboxLayout.LayoutParams.FLEX_BASIS_PERCENT_DEFAULT) {
        flexBasisPercentEdit.setText(String.valueOf(Math.round(mFlexItem.flexBasisPercent * 100)));
    } else {
        flexBasisPercentEdit.setText(String.valueOf((int) mFlexItem.flexBasisPercent));
    }
    flexBasisPercentEdit.addTextChangedListener(new FlexEditTextWatcher(flexBasisPercentInput,
            new FlexBasisPercentInputValidator(), R.string.must_be_minus_one_or_non_negative_integer));

    final TextInputLayout widthInput = (TextInputLayout) view.findViewById(R.id.input_layout_width);
    EditText widthEdit = (EditText) view.findViewById(R.id.edit_text_width);
    widthEdit.setText(String.valueOf(mFlexItem.width));
    widthEdit.addTextChangedListener(new FlexEditTextWatcher(widthInput, new DimensionInputValidator(),
            R.string.must_be_minus_one_or_minus_two_or_non_negative_integer));

    final TextInputLayout heightInput = (TextInputLayout) view.findViewById(R.id.input_layout_height);
    EditText heightEdit = (EditText) view.findViewById(R.id.edit_text_height);
    heightEdit.setText(String.valueOf(mFlexItem.height));
    heightEdit.addTextChangedListener(new FlexEditTextWatcher(heightInput, new DimensionInputValidator(),
            R.string.must_be_minus_one_or_minus_two_or_non_negative_integer));

    final TextInputLayout minWidthInput = (TextInputLayout) view.findViewById(R.id.input_layout_min_width);
    EditText minWidthEdit = (EditText) view.findViewById(R.id.edit_text_min_width);
    minWidthEdit.setText(String.valueOf(mFlexItem.minWidth));
    minWidthEdit.addTextChangedListener(new FlexEditTextWatcher(minWidthInput,
            new FixedDimensionInputValidator(), R.string.must_be_non_negative_integer));

    final TextInputLayout minHeightInput = (TextInputLayout) view.findViewById(R.id.input_layout_min_height);
    EditText minHeightEdit = (EditText) view.findViewById(R.id.edit_text_min_height);
    minHeightEdit.setText(String.valueOf(mFlexItem.minHeight));
    minHeightEdit.addTextChangedListener(new FlexEditTextWatcher(minHeightInput,
            new FixedDimensionInputValidator(), R.string.must_be_non_negative_integer));

    final TextInputLayout maxWidthInput = (TextInputLayout) view.findViewById(R.id.input_layout_max_width);
    EditText maxWidthEdit = (EditText) view.findViewById(R.id.edit_text_max_width);
    maxWidthEdit.setText(String.valueOf(mFlexItem.maxWidth));
    maxWidthEdit.addTextChangedListener(new FlexEditTextWatcher(maxWidthInput,
            new FixedDimensionInputValidator(), R.string.must_be_non_negative_integer));

    final TextInputLayout maxHeightInput = (TextInputLayout) view.findViewById(R.id.input_layout_max_height);
    EditText maxHeightEdit = (EditText) view.findViewById(R.id.edit_text_max_height);
    maxHeightEdit.setText(String.valueOf(mFlexItem.maxHeight));
    maxHeightEdit.addTextChangedListener(new FlexEditTextWatcher(maxHeightInput,
            new FixedDimensionInputValidator(), R.string.must_be_non_negative_integer));

    setNextFocusesOnEnterDown(orderEdit, flexGrowEdit, flexShrinkEdit, flexBasisPercentEdit, widthEdit,
            heightEdit, minWidthEdit, minHeightEdit, maxWidthEdit, maxHeightEdit);

    Spinner alignSelfSpinner = (Spinner) view.findViewById(R.id.spinner_align_self);
    ArrayAdapter<CharSequence> arrayAdapter = ArrayAdapter.createFromResource(getActivity(),
            R.array.array_align_self, R.layout.spinner_item);
    alignSelfSpinner.setAdapter(arrayAdapter);
    alignSelfSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            String selected = parent.getItemAtPosition(position).toString();
            if (selected.equals(ALIGN_SELF_AUTO)) {
                mFlexItem.alignSelf = FlexboxLayout.LayoutParams.ALIGN_SELF_AUTO;
            } else if (selected.equals(ALIGN_SELF_FLEX_START)) {
                mFlexItem.alignSelf = FlexboxLayout.LayoutParams.ALIGN_SELF_FLEX_START;
            } else if (selected.equals(ALIGN_SELF_FLEX_END)) {
                mFlexItem.alignSelf = FlexboxLayout.LayoutParams.ALIGN_SELF_FLEX_END;
            } else if (selected.equals(ALIGN_SELF_CENTER)) {
                mFlexItem.alignSelf = FlexboxLayout.LayoutParams.ALIGN_SELF_CENTER;
            } else if (selected.equals(ALIGN_SELF_BASELINE)) {
                mFlexItem.alignSelf = FlexboxLayout.LayoutParams.ALIGN_SELF_BASELINE;
            } else if (selected.equals(ALIGN_SELF_STRETCH)) {
                mFlexItem.alignSelf = FlexboxLayout.LayoutParams.ALIGN_SELF_STRETCH;
            }
        }

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

    CheckBox wrapBeforeCheckBox = (CheckBox) view.findViewById(R.id.checkbox_wrap_before);
    wrapBeforeCheckBox.setChecked(mFlexItem.wrapBefore);
    wrapBeforeCheckBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            mFlexItem.wrapBefore = isChecked;
        }
    });
    int alignSelfPosition = arrayAdapter.getPosition(alignSelfAsString(mFlexItem.alignSelf));
    alignSelfSpinner.setSelection(alignSelfPosition);

    view.findViewById(R.id.button_cancel).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            dismiss();
        }
    });
    final Button okButton = (Button) view.findViewById(R.id.button_ok);
    okButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (orderTextInput.isErrorEnabled() || flexGrowInput.isErrorEnabled()
                    || flexBasisPercentInput.isErrorEnabled() || widthInput.isErrorEnabled()
                    || heightInput.isErrorEnabled() || minWidthInput.isErrorEnabled()
                    || minHeightInput.isErrorEnabled() || maxWidthInput.isErrorEnabled()
                    || maxHeightInput.isErrorEnabled()) {
                Toast.makeText(getActivity(), R.string.invalid_values_exist, Toast.LENGTH_SHORT).show();
                return;
            }
            if (mFlexItemChangedListener != null) {
                mFlexItemChangedListener.onFlexItemChanged(mFlexItem);
            }
            dismiss();
        }
    });
    return view;
}