use of android.widget.Spinner in project android_frameworks_base by DirtyUnicorns.
the class SurfaceCompositionMeasuringActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
// Detect Andromeda devices by having free-form window management feature.
mAndromeda = getPackageManager().hasSystemFeature(PackageManager.FEATURE_FREEFORM_WINDOW_MANAGEMENT);
detectRefreshRate();
// To layouts in parent. First contains list of Surfaces and second
// controls. Controls stay on top.
RelativeLayout rootLayout = new RelativeLayout(this);
rootLayout.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
CustomLayout layout = new CustomLayout(this);
layout.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
Rect rect = new Rect();
getWindow().getDecorView().getWindowVisibleDisplayFrame(rect);
mWidth = rect.right;
mHeight = rect.bottom;
long maxMemoryPerSurface = roundToNextPowerOf2(mWidth) * roundToNextPowerOf2(mHeight) * 4;
// Use 75% of available memory.
int surfaceCnt = (int) ((getMemoryInfo().availMem * 3) / (4 * maxMemoryPerSurface));
if (surfaceCnt < MIN_NUMBER_OF_SURFACES) {
throw new RuntimeException("Not enough memory to allocate " + MIN_NUMBER_OF_SURFACES + " surfaces.");
}
if (surfaceCnt > MAX_NUMBER_OF_SURFACES) {
surfaceCnt = MAX_NUMBER_OF_SURFACES;
}
LinearLayout controlLayout = new LinearLayout(this);
controlLayout.setOrientation(LinearLayout.VERTICAL);
controlLayout.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
mMeasureCompositionButton = createButton("Compositor speed.", controlLayout);
mMeasureAllocationButton = createButton("Allocation speed", controlLayout);
String[] pixelFomats = new String[PIXEL_FORMATS.length];
for (int i = 0; i < pixelFomats.length; ++i) {
pixelFomats[i] = getPixelFormatInfo(PIXEL_FORMATS[i]);
}
mPixelFormatSelector = new Spinner(this);
ArrayAdapter<String> pixelFormatSelectorAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, pixelFomats);
pixelFormatSelectorAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
mPixelFormatSelector.setAdapter(pixelFormatSelectorAdapter);
mPixelFormatSelector.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
controlLayout.addView(mPixelFormatSelector);
mResultView = new TextView(this);
mResultView.setBackgroundColor(0);
mResultView.setText("Press button to start test.");
mResultView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
controlLayout.addView(mResultView);
mSystemInfoView = new TextView(this);
mSystemInfoView.setBackgroundColor(0);
mSystemInfoView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
controlLayout.addView(mSystemInfoView);
for (int i = 0; i < surfaceCnt; ++i) {
CustomSurfaceView view = new CustomSurfaceView(this, "Surface:" + i);
// to mark as media overlay.
if (i == 0) {
view.setLayoutParams(new CustomLayout.LayoutParams(0, 0, mWidth, mHeight));
view.setZOrderMediaOverlay(false);
} else {
// Z order of other layers is not predefined so make offset on x and reverse
// offset on y to make sure that surface is visible in any layout.
int x = i;
int y = (surfaceCnt - i);
view.setLayoutParams(new CustomLayout.LayoutParams(x, y, x + mWidth, y + mHeight));
view.setZOrderMediaOverlay(true);
}
view.setVisibility(View.INVISIBLE);
layout.addView(view);
mViews.add(view);
}
rootLayout.addView(layout);
rootLayout.addView(controlLayout);
setContentView(rootLayout);
}
use of android.widget.Spinner in project Etar-Calendar by Etar-Group.
the class EventViewUtils method addReminder.
/**
* Adds a reminder to the displayed list of reminders. The values/labels
* arrays must not change after calling here, or the spinners we created
* might index into the wrong entry. Returns true if successfully added
* reminder, false if no reminders can be added.
*
* onItemSelected allows a listener to be set for any changes to the
* spinners in the reminder. If a listener is set it will store the
* initial position of the spinner into the spinner's tag for comparison
* with any new position setting.
*/
public static boolean addReminder(Activity activity, View view, View.OnClickListener listener, ArrayList<LinearLayout> items, ArrayList<Integer> minuteValues, ArrayList<String> minuteLabels, ArrayList<Integer> methodValues, ArrayList<String> methodLabels, ReminderEntry newReminder, int maxReminders, OnItemSelectedListener onItemSelected) {
if (items.size() >= maxReminders) {
return false;
}
LayoutInflater inflater = activity.getLayoutInflater();
LinearLayout parent = (LinearLayout) view.findViewById(R.id.reminder_items_container);
LinearLayout reminderItem = (LinearLayout) inflater.inflate(R.layout.edit_reminder_item, null);
parent.addView(reminderItem);
ImageButton reminderRemoveButton;
reminderRemoveButton = (ImageButton) reminderItem.findViewById(R.id.reminder_remove);
reminderRemoveButton.setOnClickListener(listener);
/*
* The spinner has the default set of labels from the string resource file, but we
* want to drop in our custom set of labels because it may have additional entries.
*/
Spinner spinner = (Spinner) reminderItem.findViewById(R.id.reminder_minutes_value);
setReminderSpinnerLabels(activity, spinner, minuteLabels);
int index = findMinutesInReminderList(minuteValues, newReminder.getMinutes());
spinner.setSelection(index);
if (onItemSelected != null) {
spinner.setTag(index);
spinner.setOnItemSelectedListener(onItemSelected);
}
/*
* Configure the alert-method spinner. Methods not supported by the current Calendar
* will not be shown.
*/
spinner = (Spinner) reminderItem.findViewById(R.id.reminder_method_value);
setReminderSpinnerLabels(activity, spinner, methodLabels);
index = findMethodInReminderList(methodValues, newReminder.getMethod());
spinner.setSelection(index);
if (onItemSelected != null) {
spinner.setTag(index);
spinner.setOnItemSelectedListener(onItemSelected);
}
items.add(reminderItem);
return true;
}
use of android.widget.Spinner in project AdMoney by ErnestoGonAr.
the class EstablecerActivity method evento.
public void evento(View view) {
bandera = false;
Spinner spinner = (Spinner) findViewById(R.id.spinner);
String pregunta = spinner.getSelectedItem().toString();
EditText p1 = (EditText) findViewById(R.id.pin);
String pin = p1.getText().toString();
EditText p2 = (EditText) findViewById(R.id.pinC);
String pin2 = p2.getText().toString();
EditText r = (EditText) findViewById(R.id.pregSeg);
String resp = r.getText().toString();
if (spinner.getSelectedItemPosition() == 0) {
Toast toast = Toast.makeText(this, "Selecciona una pregunta", Toast.LENGTH_SHORT);
toast.setGravity(Gravity.CENTER_VERTICAL, 0, 0);
toast.show();
return;
}
if (resp.equals("")) {
Toast toast = Toast.makeText(this, "Escribe tu respuesta", Toast.LENGTH_SHORT);
toast.setGravity(Gravity.CENTER_VERTICAL, 0, 0);
toast.show();
return;
}
if (!(pin.length() == 4)) {
Toast toast = Toast.makeText(this, "NIP debe ser de 4 digitos", Toast.LENGTH_SHORT);
toast.setGravity(Gravity.CENTER_VERTICAL, 0, 0);
toast.show();
return;
}
if (!pin.equals(pin2)) {
Toast toast = Toast.makeText(this, "El NIP no coincide", Toast.LENGTH_SHORT);
toast.setGravity(Gravity.CENTER_VERTICAL, 0, 0);
toast.show();
return;
}
if (db.isthereData()) {
db.updateLOGINN(pin, pregunta, resp);
}
db.insertarLOGINN(pin, pregunta, resp);
bandera = true;
}
use of android.widget.Spinner in project AdMoney by ErnestoGonAr.
the class RecuperarActivity method evento.
public void evento(View v) {
bandera = false;
Spinner a = (Spinner) findViewById(R.id.spinnerPR);
String as = a.getSelectedItem().toString();
EditText b = (EditText) findViewById(R.id.editTextPR);
String bs = b.getText().toString();
if (a.getSelectedItemPosition() == 0) {
Toast toast = Toast.makeText(this, "Selecciona una pregunta de seguridad", Toast.LENGTH_SHORT);
toast.setGravity(Gravity.CENTER_VERTICAL, 0, 0);
toast.show();
return;
}
if (bs.equals("")) {
Toast toast = Toast.makeText(this, "Escribe tu respuesta", Toast.LENGTH_SHORT);
toast.setGravity(Gravity.CENTER_VERTICAL, 0, 0);
toast.show();
return;
}
bandera = true;
}
use of android.widget.Spinner in project android_frameworks_base by DirtyUnicorns.
the class ScrollingTabContainerView method createSpinner.
private Spinner createSpinner() {
final Spinner spinner = new Spinner(getContext(), null, com.android.internal.R.attr.actionDropDownStyle);
spinner.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.MATCH_PARENT));
spinner.setOnItemClickListenerInt(this);
return spinner;
}
Aggregations