Search in sources :

Example 66 with Spinner

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;
    }
}
Also used : Switch(android.widget.Switch) CustomEditText(org.eyeseetea.sdk.presentation.views.CustomEditText) Spinner(android.widget.Spinner) Option(org.eyeseetea.malariacare.data.database.model.Option)

Example 67 with Spinner

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();
        }
    });
}
Also used : EditText(android.widget.EditText) AlertDialog(android.app.AlertDialog) DialogInterface(android.content.DialogInterface) Spinner(android.widget.Spinner) Bundle(android.os.Bundle) Intent(android.content.Intent) View(android.view.View) CategoryNode(org.wordpress.android.models.CategoryNode) Button(android.widget.Button) TermModel(org.wordpress.android.fluxc.model.TermModel)

Example 68 with Spinner

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);
    }
}
Also used : CategoryNode(org.wordpress.android.models.CategoryNode) Spinner(android.widget.Spinner)

Example 69 with Spinner

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;
}
Also used : Spinner(android.widget.Spinner) TextView(android.widget.TextView) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) View(android.view.View) AdapterView(android.widget.AdapterView) Nullable(android.support.annotation.Nullable)

Example 70 with Spinner

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);
}
Also used : Spinner(android.widget.Spinner) ArrayAdapter(android.widget.ArrayAdapter) AutoCompleteTextView(android.widget.AutoCompleteTextView)

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