Search in sources :

Example 16 with OnItemSelectedListener

use of android.widget.AdapterView.OnItemSelectedListener in project Diaspora-Webclient by voidcode.

the class TranslateActivity method fillLanguageSpinner.

public void fillLanguageSpinner() {
    spinnerLanguage = (Spinner) findViewById(R.id.translate_spinner_language);
    spinnerLanguage.setAdapter(new ArrayAdapter<Language>(this, android.R.layout.simple_spinner_item, Language.values()));
    //
    spinnerLanguage.setSelection(this.current_select_language_in_spinner);
    spinnerLanguage.setOnItemSelectedListener(new OnItemSelectedListener() {

        public void onItemSelected(AdapterView<?> parent, View v, int pos, long id) {
            // Set default-languages.
            SharedPreferences preferences = getSharedPreferences(TRANSLATE_FILENAME, MODE_PRIVATE);
            SharedPreferences.Editor editor = preferences.edit();
            editor.putInt("current_select_language_in_spinner", pos);
            editor.putString("defaultlanguage", Language.fromString(parent.getItemAtPosition(pos).toString()).shortCode());
            editor.commit();
        }

        public void onNothingSelected(AdapterView<?> parent) {
        }
    });
}
Also used : SharedPreferences(android.content.SharedPreferences) OnItemSelectedListener(android.widget.AdapterView.OnItemSelectedListener) View(android.view.View) AdapterView(android.widget.AdapterView)

Example 17 with OnItemSelectedListener

use of android.widget.AdapterView.OnItemSelectedListener in project AndroidChromium by JackyAndroid.

the class DistilledPagePrefsView method initFontFamilySpinner.

private void initFontFamilySpinner() {
    ArrayAdapter<CharSequence> adapter = new ArrayAdapter<CharSequence>(getContext(), android.R.layout.simple_spinner_item, getResources().getStringArray(R.array.distiller_mode_font_family_values)) {

        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            View view = super.getView(position, convertView, parent);
            return overrideTypeFace(view, position);
        }

        @Override
        public View getDropDownView(int position, View convertView, ViewGroup parent) {
            View view = super.getDropDownView(position, convertView, parent);
            return overrideTypeFace(view, position);
        }

        private View overrideTypeFace(View view, int position) {
            if (view instanceof TextView) {
                TextView textView = (TextView) view;
                FontFamily family = FontFamily.values()[position];
                if (family == FontFamily.MONOSPACE) {
                    textView.setTypeface(Typeface.MONOSPACE);
                } else if (family == FontFamily.SANS_SERIF) {
                    textView.setTypeface(Typeface.SANS_SERIF);
                } else if (family == FontFamily.SERIF) {
                    textView.setTypeface(Typeface.SERIF);
                }
            }
            return view;
        }
    };
    adapter.setDropDownViewResource(R.layout.distilled_page_font_family_spinner);
    mFontFamilySpinner.setAdapter(adapter);
    mFontFamilySpinner.setSelection(mDistilledPagePrefs.getFontFamily().ordinal());
    mFontFamilySpinner.setOnItemSelectedListener(new OnItemSelectedListener() {

        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            FontFamily family = FontFamily.getFontFamilyForValue(position);
            if (family != null) {
                mDistilledPagePrefs.setFontFamily(family);
            }
        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {
        // Nothing to do.
        }
    });
}
Also used : FontFamily(org.chromium.components.dom_distiller.core.FontFamily) ViewGroup(android.view.ViewGroup) OnItemSelectedListener(android.widget.AdapterView.OnItemSelectedListener) TextView(android.widget.TextView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ArrayAdapter(android.widget.ArrayAdapter)

Example 18 with OnItemSelectedListener

use of android.widget.AdapterView.OnItemSelectedListener in project LiveSDK-for-Android by liveservices.

the class ExplorerActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.explorer);
    LiveSdkSampleApplication app = (LiveSdkSampleApplication) getApplication();
    mConnectClient = app.getConnectClient();
    mOperationListener = new OperationListener();
    mResponseBodyText = (EditText) findViewById(R.id.responseBodyText);
    mPathText = (EditText) findViewById(R.id.pathText);
    mRequestBodyText = (EditText) findViewById(R.id.requestBodyText);
    mRequestBodyTextView = (TextView) findViewById(R.id.requestBodyTextView);
    final Spinner httpMethodSpinner = (Spinner) findViewById(R.id.httpMethodSpinner);
    ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, HTTP_METHODS);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    httpMethodSpinner.setAdapter(adapter);
    httpMethodSpinner.setOnItemSelectedListener(new OnItemSelectedListener() {

        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            switch(position) {
                case GET:
                case DELETE:
                    hideRequestBody();
                    break;
                case POST:
                case PUT:
                    showRequestBody();
                    break;
                default:
                    {
                        makeToast("Unknown HTTP method selected: " + httpMethodSpinner.getSelectedItem().toString());
                        break;
                    }
            }
        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {
        // Do nothing.
        }
    });
    findViewById(R.id.submitButton).setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            String path = mPathText.getText().toString();
            String bodyString = mRequestBodyText.getText().toString();
            if (TextUtils.isEmpty(path)) {
                makeToast("Path must not be empty.");
                return;
            }
            int selectedPosition = httpMethodSpinner.getSelectedItemPosition();
            boolean httpMethodRequiresBody = selectedPosition == POST || selectedPosition == PUT;
            if (httpMethodRequiresBody && TextUtils.isEmpty(bodyString)) {
                makeToast("Request body must not be empty.");
                return;
            }
            mProgressDialog = showProgressDialog("Loading. Please wait...");
            switch(selectedPosition) {
                case GET:
                    {
                        mConnectClient.getAsync(path, mOperationListener);
                        break;
                    }
                case DELETE:
                    {
                        mConnectClient.deleteAsync(path, mOperationListener);
                        break;
                    }
                case POST:
                    {
                        mConnectClient.postAsync(path, bodyString, mOperationListener);
                        break;
                    }
                case PUT:
                    {
                        mConnectClient.putAsync(path, bodyString, mOperationListener);
                        break;
                    }
                default:
                    {
                        makeToast("Unknown HTTP method selected: " + httpMethodSpinner.getSelectedItem().toString());
                        break;
                    }
            }
        }
    });
}
Also used : LiveOperationListener(com.microsoft.live.LiveOperationListener) Spinner(android.widget.Spinner) TextView(android.widget.TextView) View(android.view.View) AdapterView(android.widget.AdapterView) OnItemSelectedListener(android.widget.AdapterView.OnItemSelectedListener) OnClickListener(android.view.View.OnClickListener) ArrayAdapter(android.widget.ArrayAdapter)

Example 19 with OnItemSelectedListener

use of android.widget.AdapterView.OnItemSelectedListener in project Etar-Calendar by Etar-Group.

the class EventInfoFragment method onActivityCreated.

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    mReminderChangeListener = new OnItemSelectedListener() {

        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            Integer prevValue = (Integer) parent.getTag();
            if (prevValue == null || prevValue != position) {
                parent.setTag(position);
                mUserModifiedReminders = true;
            }
        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {
        // do nothing
        }
    };
    if (savedInstanceState != null) {
        mIsDialog = savedInstanceState.getBoolean(BUNDLE_KEY_IS_DIALOG, false);
        mWindowStyle = savedInstanceState.getInt(BUNDLE_KEY_WINDOW_STYLE, DIALOG_WINDOW_STYLE);
    }
    if (mIsDialog) {
        applyDialogParams();
    }
    final Activity activity = getActivity();
    mContext = activity;
    dynamicTheme.onCreate(activity);
    mColorPickerDialog = (EventColorPickerDialog) activity.getFragmentManager().findFragmentByTag(COLOR_PICKER_DIALOG_TAG);
    if (mColorPickerDialog != null) {
        mColorPickerDialog.setOnColorSelectedListener(this);
    }
}
Also used : OnItemSelectedListener(android.widget.AdapterView.OnItemSelectedListener) QuickResponseActivity(com.android.calendar.alerts.QuickResponseActivity) EditEventActivity(com.android.calendar.event.EditEventActivity) Activity(android.app.Activity) ScrollView(android.widget.ScrollView) View(android.view.View) AdapterView(android.widget.AdapterView) AttendeesView(com.android.calendar.event.AttendeesView) TextView(android.widget.TextView)

Example 20 with OnItemSelectedListener

use of android.widget.AdapterView.OnItemSelectedListener in project ETSMobile-Android2 by ApplETS.

the class ContactAdderFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.contactadder, container, false);
    Log.v(TAG, "Activity State: onCreate()");
    // final Bundle extras = getArguments();
    //
    // nom = BottinDetailsFragment.NOM;
    // prenom = BottinDetailsFragment.PRENOM;
    // service = BottinDetailsFragment.SERVICE;
    // // empl = extras.getString("empl");
    // titre = BottinDetailsFragment.TITRE;
    // courriel = BottinDetailsFragment.COURRIEL;
    // phone = BottinDetailsFragment.TELBUREAU;
    // Obtain handles to UI objects
    mAccountSpinner = (Spinner) v.findViewById(R.id.accountSpinner);
    mContactNameEditText = (EditText) v.findViewById(R.id.contactNameEditText);
    System.out.println(prenom);
    mContactNameEditText.setText(prenom + " " + nom);
    mContactPhoneEditText = (EditText) v.findViewById(R.id.contactPhoneEditText);
    mContactPhoneEditText.setText(phone);
    mContactEmailEditText = (EditText) v.findViewById(R.id.contactEmailEditText);
    mContactEmailEditText.setText(courriel);
    mContactPhoneTypeSpinner = (Spinner) v.findViewById(R.id.contactPhoneTypeSpinner);
    mContactEmailTypeSpinner = (Spinner) v.findViewById(R.id.contactEmailTypeSpinner);
    mContactAddressEditText = (EditText) v.findViewById(R.id.addressEditText);
    mContactAddressEditText.setText(empl);
    mContactSaveButton = (Button) v.findViewById(R.id.contactSaveButton);
    // Prepare list of supported account types
    // Note: Other types are available in ContactsContract.CommonDataKinds
    // Also, be aware that type IDs differ between Phone and Email, and MUST
    // be computed
    // separately.
    mContactPhoneTypes = new ArrayList<Integer>();
    mContactPhoneTypes.add(ContactsContract.CommonDataKinds.Phone.TYPE_HOME);
    mContactPhoneTypes.add(ContactsContract.CommonDataKinds.Phone.TYPE_WORK);
    mContactPhoneTypes.add(ContactsContract.CommonDataKinds.Phone.TYPE_MOBILE);
    mContactPhoneTypes.add(ContactsContract.CommonDataKinds.Phone.TYPE_OTHER);
    mContactEmailTypes = new ArrayList<Integer>();
    mContactEmailTypes.add(ContactsContract.CommonDataKinds.Email.TYPE_HOME);
    mContactEmailTypes.add(ContactsContract.CommonDataKinds.Email.TYPE_WORK);
    mContactEmailTypes.add(ContactsContract.CommonDataKinds.Email.TYPE_MOBILE);
    mContactEmailTypes.add(ContactsContract.CommonDataKinds.Email.TYPE_OTHER);
    // Prepare model for account spinner
    mAccounts = new ArrayList<AccountData>();
    mAccountAdapter = new AccountAdapter(getActivity(), mAccounts);
    mAccountSpinner.setAdapter(mAccountAdapter);
    // Populate list of account types for phone
    ArrayAdapter<String> adapter;
    adapter = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_spinner_item);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    Iterator<Integer> iter;
    iter = mContactPhoneTypes.iterator();
    while (iter.hasNext()) {
        adapter.add(ContactsContract.CommonDataKinds.Phone.getTypeLabel(this.getResources(), iter.next(), "undefined").toString());
    }
    mContactPhoneTypeSpinner.setAdapter(adapter);
    mContactPhoneTypeSpinner.setPrompt("select");
    // Populate list of account types for email
    adapter = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_spinner_item);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    iter = mContactEmailTypes.iterator();
    while (iter.hasNext()) {
        adapter.add(ContactsContract.CommonDataKinds.Email.getTypeLabel(this.getResources(), iter.next(), "undefined").toString());
    }
    mContactEmailTypeSpinner.setAdapter(adapter);
    mContactEmailTypeSpinner.setPrompt("select");
    // Prepare the system account manager. On registering the listener
    // below, we also ask for
    // an initial callback to pre-populate the account list.
    AccountManager.get(getActivity()).addOnAccountsUpdatedListener(this, null, true);
    // Register handlers for UI elements
    mAccountSpinner.setOnItemSelectedListener(new OnItemSelectedListener() {

        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long i) {
            updateAccountSelection();
        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {
        // We don't need to worry about nothing being selected, since
        // Spinners don't allow
        // this.
        }
    });
    mContactSaveButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            onSaveButtonClicked();
        }
    });
    return v;
}
Also used : ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) OnItemSelectedListener(android.widget.AdapterView.OnItemSelectedListener)

Aggregations

OnItemSelectedListener (android.widget.AdapterView.OnItemSelectedListener)25 View (android.view.View)23 AdapterView (android.widget.AdapterView)21 TextView (android.widget.TextView)14 ArrayAdapter (android.widget.ArrayAdapter)11 OnClickListener (android.view.View.OnClickListener)10 ImageView (android.widget.ImageView)9 ListView (android.widget.ListView)6 Spinner (android.widget.Spinner)6 MotionEvent (android.view.MotionEvent)5 PrintContentView (com.android.printspooler.widget.PrintContentView)5 DialogInterface (android.content.DialogInterface)4 Intent (android.content.Intent)3 SharedPreferences (android.content.SharedPreferences)3 Editable (android.text.Editable)3 CompoundButton (android.widget.CompoundButton)3 EditText (android.widget.EditText)3 SuppressLint (android.annotation.SuppressLint)2 AlertDialog (android.app.AlertDialog)2 Bundle (android.os.Bundle)2