use of android.widget.Spinner in project pictureapp by EyeSeeTea.
the class AQuestionAnswerChangedListener method showDefaultValue.
/**
* when a question is shown this method set the correct value.
*
* @param rowQuestion is the question in the view
*/
private void showDefaultValue(TableRow tableRow, Question rowQuestion) {
if (rowQuestion.getValueBySession() != null) {
return;
}
switch(rowQuestion.getOutput()) {
case Constants.PHONE:
case Constants.POSITIVE_INT:
case Constants.INT:
case Constants.LONG_TEXT:
case Constants.SHORT_TEXT:
final CustomEditText editCard = (CustomEditText) tableRow.findViewById(R.id.answer);
editCard.setText("");
break;
case Constants.DROPDOWN_LIST:
case Constants.DROPDOWN_OU_LIST:
Spinner dropdown = (Spinner) tableRow.findViewById(R.id.answer);
dropdown.setSelection(0);
break;
case Constants.SWITCH_BUTTON:
Switch switchView = (Switch) tableRow.findViewById(R.id.answer);
Option selectedOption = rowQuestion.getOptionBySession();
if (selectedOption == null) {
//the 0 option is the left option and is false in the switch, the 1 option is
// the right option and is true
boolean isChecked = false;
if (rowQuestion.getAnswer().getOptions().get(1).getOptionAttribute().getDefaultOption() == 1) {
isChecked = true;
}
saveSwitchOption(rowQuestion, isChecked);
switchView.setChecked(isChecked);
break;
}
switchView.setChecked(findSwitchBoolean(rowQuestion));
break;
}
}
use of android.widget.Spinner in project WordPress-Android by wordpress-mobile.
the class AddCategoryActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
((WordPress) getApplication()).component().inject(this);
setContentView(R.layout.add_category);
if (savedInstanceState == null) {
mSite = (SiteModel) getIntent().getSerializableExtra(WordPress.SITE);
} else {
mSite = (SiteModel) savedInstanceState.getSerializable(WordPress.SITE);
}
if (mSite == null) {
ToastUtils.showToast(this, R.string.blog_not_found, ToastUtils.Duration.SHORT);
finish();
return;
}
loadCategories();
final Button cancelButton = (Button) findViewById(R.id.cancel);
final Button okButton = (Button) findViewById(R.id.ok);
okButton.setOnClickListener(new Button.OnClickListener() {
public void onClick(View v) {
String categoryName = ((EditText) findViewById(R.id.category_name)).getText().toString();
String categoryDesc = ((EditText) findViewById(R.id.category_desc)).getText().toString();
Spinner categorySpinner = (Spinner) findViewById(R.id.parent_category);
CategoryNode selectedCategory = (CategoryNode) categorySpinner.getSelectedItem();
long parentId = (selectedCategory != null) ? selectedCategory.getCategoryId() : 0;
if (categoryName.replaceAll(" ", "").equals("")) {
// Name field cannot be empty
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(AddCategoryActivity.this);
dialogBuilder.setTitle(getResources().getText(R.string.required_field));
dialogBuilder.setMessage(getResources().getText(R.string.cat_name_required));
dialogBuilder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
// Just close the window.
}
});
dialogBuilder.setCancelable(true);
dialogBuilder.create().show();
} else {
Bundle bundle = new Bundle();
TermModel newCategory = new TermModel();
newCategory.setTaxonomy(TaxonomyStore.DEFAULT_TAXONOMY_CATEGORY);
newCategory.setName(categoryName);
newCategory.setDescription(categoryDesc);
newCategory.setParentRemoteId(parentId);
bundle.putSerializable(KEY_CATEGORY, newCategory);
Intent mIntent = new Intent();
mIntent.putExtras(bundle);
setResult(RESULT_OK, mIntent);
finish();
}
}
});
cancelButton.setOnClickListener(new Button.OnClickListener() {
public void onClick(View v) {
Intent mIntent = new Intent();
setResult(RESULT_CANCELED, mIntent);
finish();
}
});
}
use of android.widget.Spinner in project WordPress-Android by wordpress-mobile.
the class AddCategoryActivity method loadCategories.
private void loadCategories() {
CategoryNode rootCategory = CategoryNode.createCategoryTreeFromList(mTaxonomyStore.getCategoriesForSite(mSite));
ArrayList<CategoryNode> categoryLevels = CategoryNode.getSortedListOfCategoriesFromRoot(rootCategory);
categoryLevels.add(0, new CategoryNode(0, 0, getString(R.string.none)));
if (categoryLevels.size() > 0) {
ParentCategorySpinnerAdapter categoryAdapter = new ParentCategorySpinnerAdapter(this, R.layout.categories_row_parent, categoryLevels);
Spinner sCategories = (Spinner) findViewById(R.id.parent_category);
sCategories.setAdapter(categoryAdapter);
}
}
use of android.widget.Spinner in project SuperToasts by JohnPersano.
the class AttributeSpinnerFragment method onCreateView.
@Nullable
@Override
@SuppressWarnings("ConstantConditions")
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
final View view = inflater.inflate(R.layout.fragment_attribute_spinner, container, false);
if (this.getArguments() == null) {
throw new IllegalArgumentException(getClass().getName().concat(" cannot be " + "instantiated without arguments."));
}
final TextView titleTextView = (TextView) view.findViewById(R.id.title);
titleTextView.setText(getArguments().getString(ARG_SUBTITLE));
final TextView summaryTextView = (TextView) view.findViewById(R.id.summary);
summaryTextView.setText(getArguments().getString(ARG_SUMMARY));
final Spinner spinner = (Spinner) view.findViewById(R.id.spinner);
spinner.setAdapter(new ArrayAdapter<>(getActivity(), android.R.layout.simple_spinner_dropdown_item, getArguments().getStringArray(ARG_ARRAY_ID)));
spinner.setSelection(PreferenceManager.getDefaultSharedPreferences(getActivity()).getInt(getArguments().getString(ARG_TITLE), 0));
spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
PreferenceManager.getDefaultSharedPreferences(getActivity()).edit().putInt(getArguments().getString(ARG_TITLE), position).commit();
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
// Do nothing
}
});
return view;
}
use of android.widget.Spinner in project android_frameworks_base by crdroidandroid.
the class PopupWindowVisibility method onCreate.
@Override
protected void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.popup_window_visibility);
mFrame = findViewById(R.id.frame);
mHide = (Button) findViewById(R.id.hide);
mHide.setOnClickListener(this);
mShow = (Button) findViewById(R.id.show);
mShow.setOnClickListener(this);
Spinner spinner = (Spinner) findViewById(R.id.spinner);
ArrayAdapter<String> spinnerAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, mStrings);
spinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner.setAdapter(spinnerAdapter);
ArrayAdapter<String> autoAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_dropdown_item_1line, COUNTRIES);
AutoCompleteTextView textView = (AutoCompleteTextView) findViewById(R.id.auto);
textView.setAdapter(autoAdapter);
}
Aggregations