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) {
}
});
}
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;
}
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);
}
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) {
}
});
}
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) {
}
});
}
Aggregations