List of usage examples for android.widget AdapterView.OnItemSelectedListener AdapterView.OnItemSelectedListener
AdapterView.OnItemSelectedListener
From source file:io.oceanos.shaderbox.dialog.PropertiesDialogFragment.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); LayoutInflater inflater = getActivity().getLayoutInflater(); final Shader shader = (Shader) getArguments().getSerializable("shader"); View view = inflater.inflate(R.layout.dialog_properties, null); final EditText nameView = (EditText) view.findViewById(R.id.name); Switch vrMode = (Switch) view.findViewById(R.id.vr_mode); Switch preview = (Switch) view.findViewById(R.id.preview); Spinner resolutionFactor = (Spinner) view.findViewById(R.id.resolution_factor); resolutionFactor.setSelection(Integer.numberOfTrailingZeros(shader.getResolution())); resolutionFactor.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override/* w w w. ja v a 2 s . co m*/ public void onItemSelected(AdapterView<?> adapterView, View view, int pos, long id) { shader.setResolution(1 << pos); } @Override public void onNothingSelected(AdapterView<?> adapterView) { } }); nameView.setText(shader.getName()); vrMode.setChecked(shader.getVrMode() == 1); vrMode.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { shader.setVrMode(isChecked ? 1 : 0); } }); preview.setChecked(shader.getPreviewMode() == 1); preview.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { shader.setPreviewMode(isChecked ? 1 : 0); } }); builder.setTitle(R.string.properties).setView(view) .setPositiveButton(R.string.save, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { shader.setName(nameView.getText().toString()); mListener.onSave(shader); } }).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { mListener.onCancel(shader); } }); return builder.create(); }
From source file:com.QuarkLabs.BTCeClient.fragments.OrdersBookFragment.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mPairsSpinner = (Spinner) LayoutInflater.from(getActivity()).inflate(R.layout.spinner, null); mPairsSpinner.setAdapter(new ArrayAdapter<>(getActivity(), android.R.layout.simple_list_item_1, getResources().getStringArray(R.array.ExchangePairs))); //restoring spinner position if (savedInstanceState != null) { mPairsSpinner.setSelection(savedInstanceState.getInt("position")); }/*w ww .java2 s . co m*/ mPairsSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { String selected = parent.getSelectedItem().toString(); Bundle bundle = new Bundle(); bundle.putString("pair", selected); if (mFragmentOpenedFirstTime) { getLoaderManager().initLoader(LOADER_ID, bundle, OrdersBookFragment.this); mFragmentOpenedFirstTime = false; } else { getLoaderManager().restartLoader(LOADER_ID, bundle, OrdersBookFragment.this); } } @Override public void onNothingSelected(AdapterView<?> parent) { } }); mAsksAdapter = new OrdersBookAdapter(getActivity()); mBidsAdapter = new OrdersBookAdapter(getActivity()); }
From source file:net.alchemiestick.katana.winehqappdb.filter_dialog.java
public filter_dialog(Context cx, List<NameValuePair> data) { super(cx);//from w ww .j av a2s . co m this.cx = cx; this.webData = data; this.requestWindowFeature(Window.FEATURE_NO_TITLE); vocl = new View.OnClickListener() { public void onClick(View v) { onCheckboxClick(v); } }; maxLines = new OnEditorActionListener() { @Override public boolean onEditorAction(TextView tv, int action, KeyEvent key) { boolean handled = false; if (action == EditorInfo.IME_ACTION_DONE) { setMaxLines(tv.getText().toString()); tv.setText(getNamedData("iPage")); InputMethodManager imm = (InputMethodManager) tv.getContext() .getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(tv.getWindowToken(), 0); handled = true; } return handled; } }; rateListener = new AdapterView.OnItemSelectedListener() { public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) { rateSelected((String) parent.getItemAtPosition(pos)); } public void onNothingSelected(AdapterView<?> parent) { } }; licenseListener = new AdapterView.OnItemSelectedListener() { public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) { licenseSelected((String) parent.getItemAtPosition(pos)); } public void onNothingSelected(AdapterView<?> parent) { } }; placementListener = new AdapterView.OnItemSelectedListener() { public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) { placementSelected((String) parent.getItemAtPosition(pos)); } public void onNothingSelected(AdapterView<?> parent) { } }; }
From source file:com.cse3310.phms.ui.activities.AddAppointmentActivity.java
@AfterViews void onSetupViews() { if (mSelectedDate != null) { appointmentTime = mSelectedDate.getTime(); }//from w ww. j a va 2 s . c o m // set spinner to get early reminder time ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.early_reminder_chose, android.R.layout.simple_spinner_item); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); mReminderSpinner.setAdapter(adapter); mReminderSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { switch (position) { case 0: earlyMillis = 0; break; case 1: earlyMillis = TimeUnit.MINUTES.toMillis(5); break; case 2: earlyMillis = TimeUnit.MINUTES.toMillis(10); break; case 3: earlyMillis = TimeUnit.MINUTES.toMillis(30); break; case 4: earlyMillis = TimeUnit.HOURS.toMillis(1); break; case 5: earlyMillis = TimeUnit.HOURS.toMillis(2); break; case 6: earlyMillis = TimeUnit.HOURS.toMillis(12); break; case 7: earlyMillis = TimeUnit.HOURS.toMillis(24); break; case 8: earlyMillis = TimeUnit.DAYS.toMillis(2); break; case 9: earlyMillis = TimeUnit.DAYS.toMillis(7); break; } } @Override public void onNothingSelected(AdapterView<?> parent) { } }); mAppointmentView.setVisibility(View.GONE); mTimeButtonTextView.setText(MyDateFormatter.formatTime(mSelectedDate.getTime())); }
From source file:org.thaliproject.nativetest.app.fragments.PeerListFragment.java
public synchronized void setListener(Listener listener) { mListener = listener;//from w ww . ja va 2s . c om if (mListener != null && mListView != null) { mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, int index, long l) { mSelectedPeerProperties = (PeerProperties) mListView.getItemAtPosition(index); Log.i(TAG, "onItemClick: " + mSelectedPeerProperties.toString()); if (mListener != null) { mListener.onPeerSelected(mSelectedPeerProperties); } } }); mListView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> adapterView, View view, int index, long l) { mSelectedPeerProperties = (PeerProperties) mListView.getItemAtPosition(index); Log.i(TAG, "onItemLongClick: " + mSelectedPeerProperties.toString()); if (mListener != null) { mListener.onPeerSelected(mSelectedPeerProperties); } return false; // Let the event propagate } }); mListView.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> adapterView, View view, int index, long l) { mSelectedPeerProperties = (PeerProperties) mListView.getItemAtPosition(index); Log.i(TAG, "onItemSelected: " + mSelectedPeerProperties.toString()); if (mListener != null) { mListener.onPeerSelected(mSelectedPeerProperties); } } @Override public void onNothingSelected(AdapterView<?> adapterView) { } }); } }
From source file:org.irmacard.cardemu.selfenrol.EnrollSelectActivity.java
/** * Called when the user presses the continue button *//*ww w.j a va 2 s . c o m*/ protected void advanceScreen() { switch (screen) { case SCREEN_START: setContentView(R.layout.enroll_activity_bac); screen = SCREEN_BAC; updateProgressCounter(screen - 1); Spinner spinner = (Spinner) findViewById(R.id.bac_selector); ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.document_list, 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) { Log.v(TAG, (String) parent.getItemAtPosition(position)); RelativeLayout drivers_license = (RelativeLayout) findViewById(R.id.drivers_license_data); RelativeLayout passport = (RelativeLayout) findViewById(R.id.passport_data); if (position == 0) { drivers_license.setVisibility(View.GONE); passport.setVisibility(View.VISIBLE); next_activity = PASSPORT_ACTIVITY; } else if (position == 1) { drivers_license.setVisibility(View.VISIBLE); passport.setVisibility(View.GONE); next_activity = DL_ACTIVITY; } else { throw new IllegalArgumentException("Pulldown list provided unspecified argument"); } if (bacFieldWatcher != null) bacFieldWatcher.onTextChanged("", 0, 0, 0); } @Override public void onNothingSelected(AdapterView<?> parent) { // TODO Auto-generated method stub } }); spinner.setSelection(settings.getInt("enroll_document", PASSPORT_ACTIVITY)); populateBacAndBapFields(); EditText docnrEditText; EditText dobEditText; EditText doeEditText; long bacDob; long bacDoe; enableContinueButton(); setBacFieldWatcher(); break; case SCREEN_BAC: if (next_activity == PASSPORT_ACTIVITY) { // Store the entered document number and dates in the settings. docnrEditText = (EditText) findViewById(R.id.doc_nr_edittext); dobEditText = (EditText) findViewById(R.id.dob_edittext); doeEditText = (EditText) findViewById(R.id.doe_edittext); if (docnrEditText != null && dobEditText != null && doeEditText != null) { bacDob = 0; bacDoe = 0; try { String dobString = dobEditText.getText().toString(); String doeString = doeEditText.getText().toString(); if (dobString.length() != 0) bacDob = hrDateFormat.parse(dobString).getTime(); if (doeString.length() != 0) bacDoe = hrDateFormat.parse(doeString).getTime(); } catch (ParseException e) { // Should not happen: the DOB and DOE EditTexts are set only by the DatePicker's, // OnDateSetListener, which should always set a properly formatted string. e.printStackTrace(); } if (bacDoe < System.currentTimeMillis()) { showErrorScreen(getString(R.string.error_enroll_passport_expired), getString(R.string.abort), 0, getString(R.string.retry), SCREEN_BAC); return; } settings.edit().putInt("enroll_document", next_activity).putLong("enroll_bac_dob", bacDob) .putLong("enroll_bac_doe", bacDoe) .putString("enroll_bac_docnr", docnrEditText.getText().toString()).apply(); } Intent i = new Intent(this, PassportEnrollActivity.class); startActivityForResult(i, PassportEnrollActivity.PassportEnrollActivityCode); } else if (next_activity == DL_ACTIVITY) { //safe the mrz text field for later. EditText mrzText = (EditText) findViewById(R.id.mrz); if (mrzText != null) { settings.edit().putInt("enroll_document", next_activity) .putString("mrz", mrzText.getText().toString()).apply(); } //TODO handle DL GUI Intent i = new Intent(this, DriversLicenseEnrollActivity.class); startActivityForResult(i, DriversLicenseEnrollActivity.DriversLicenseEnrollActivityCode); } else { throw new IllegalStateException("Enroll Activity advancing an unknown screen: " + screen); } break; case SCREEN_ISSUE: case SCREEN_ERROR: screen = SCREEN_START; finish(); break; default: Log.e(TAG, "Error, screen switch fall through: " + screen); break; } }
From source file:com.esri.arcgisruntime.sample.blendrenderer.ParametersDialogFragment.java
/** * Builds parameter dialog with values pulled through from MainActivity. * * @param savedInstanceState/* w w w . j av a2 s .com*/ * @return create parameter dialog box */ @NonNull @Override public Dialog onCreateDialog(Bundle savedInstanceState) { LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); Bundle blendParameters = getArguments(); if (blendParameters != null) { mAltitude = blendParameters.getInt("altitude"); mAzimuth = blendParameters.getInt("azimuth"); mSlopeType = (SlopeType) blendParameters.getSerializable("slope_type"); mColorRampType = (ColorRamp.PresetType) blendParameters.getSerializable("color_ramp_type"); } final AlertDialog.Builder paramDialog = new AlertDialog.Builder(getContext()); @SuppressLint("InflateParams") View dialogView = inflater.inflate(R.layout.dialog_box, null); paramDialog.setView(dialogView); paramDialog.setTitle(R.string.dialog_title); paramDialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dismiss(); } }); paramDialog.setPositiveButton("Render", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); ParametersListener activity = (ParametersListener) getActivity(); activity.returnParameters(mAltitude, mAzimuth, mSlopeType, mColorRampType); } }); mCurrAltitudeTextView = (TextView) dialogView.findViewById(R.id.curr_altitude_text); SeekBar altitudeSeekBar = (SeekBar) dialogView.findViewById(R.id.altitude_seek_bar); altitudeSeekBar.setMax(90); //altitude is restricted to 0 - 90 //set initial altitude value updateAltitudeSeekBar(altitudeSeekBar); altitudeSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { mAltitude = progress; updateAltitudeSeekBar(seekBar); } @Override public void onStartTrackingTouch(SeekBar seekBar) { } @Override public void onStopTrackingTouch(SeekBar seekBar) { } }); mCurrAzimuthTextView = (TextView) dialogView.findViewById(R.id.curr_azimuth_text); SeekBar azimuthSeekBar = (SeekBar) dialogView.findViewById(R.id.azimuth_seek_bar); azimuthSeekBar.setMax(360); //azimuth measured in degrees 0 - 360 //set initial azimuth value updateAzimuthSeekBar(azimuthSeekBar); azimuthSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { mAzimuth = progress; updateAzimuthSeekBar(seekBar); } @Override public void onStartTrackingTouch(SeekBar seekBar) { } @Override public void onStopTrackingTouch(SeekBar seekBar) { } }); List<String> slopeTypeArray = new ArrayList<>(); slopeTypeArray.add("None"); //ordinals:0 slopeTypeArray.add("Degree"); //1 slopeTypeArray.add("Percent rise"); //2 slopeTypeArray.add("Scaled"); //3 ArrayAdapter<String> slopeTypeSpinnerAdapter = new ArrayAdapter<>(getContext(), R.layout.spinner_text_view, slopeTypeArray); Spinner slopeTypeSpinner = (Spinner) dialogView.findViewById(R.id.slope_type_spinner); slopeTypeSpinner.setAdapter(slopeTypeSpinnerAdapter); slopeTypeSpinner.setSelection(mSlopeType.ordinal()); slopeTypeSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { switch (position) { case 0: mSlopeType = SlopeType.NONE; break; case 1: mSlopeType = SlopeType.DEGREE; break; case 2: mSlopeType = SlopeType.PERCENT_RISE; break; case 3: mSlopeType = SlopeType.SCALED; break; } } @Override public void onNothingSelected(AdapterView<?> parent) { } }); List<String> colorRampTypeArray = new ArrayList<>(); colorRampTypeArray.add("None"); //ordinals:0 colorRampTypeArray.add("Elevation"); //1 colorRampTypeArray.add("DEM screen"); //2 colorRampTypeArray.add("DEM light"); //3 ArrayAdapter<String> colorRampSpinnerAdapter = new ArrayAdapter<>(getContext(), R.layout.spinner_text_view, colorRampTypeArray); Spinner colorRampSpinner = (Spinner) dialogView.findViewById(R.id.color_ramp_spinner); colorRampSpinner.setAdapter(colorRampSpinnerAdapter); colorRampSpinner.setSelection(mColorRampType.ordinal()); colorRampSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { switch (position) { case 0: mColorRampType = ColorRamp.PresetType.NONE; break; case 1: mColorRampType = ColorRamp.PresetType.ELEVATION; break; case 2: mColorRampType = ColorRamp.PresetType.DEM_SCREEN; break; case 3: mColorRampType = ColorRamp.PresetType.DEM_LIGHT; break; } } @Override public void onNothingSelected(AdapterView<?> parent) { } }); return paramDialog.create(); }
From source file:net.palacesoft.cngstation.client.StationActivity.java
private void initSearchForm() { countries = (Spinner) findViewById(R.id.countries); countries.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override/*from www. ja v a 2s. c om*/ public void onItemSelected(AdapterView<?> adapterView, View view, int pos, long l) { String country = adapterView.getItemAtPosition(pos).toString(); new CityLoader(StationActivity.this, country).execute(CITIES_URL); } @Override public void onNothingSelected(AdapterView<?> adapterView) { } }); cities = (Spinner) findViewById(R.id.cities); Button btnSubmit = (Button) findViewById(R.id.btnSubmit); btnSubmit.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Object selection = cities.getSelectedItem(); if (selection != null && hasText(selection.toString())) { String city = selection.toString(); try { Address address = lookupAddressFromLocationName(city, countries.getSelectedItem().toString()); new StationLoader(StationActivity.this, address, getZoomLevel(), STATIONS_URL).execute(); } catch (Exception e) { showInfoMessage("Problem finding CNG stations for chosen location"); } } } }); }
From source file:org.thaliproject.nativetest.app.fragments.SettingsFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_settings, container, false); mSettings = Settings.getInstance(view.getContext()); mSettings.load();/*from w w w . j a v a2 s . co m*/ mConnectionTimeoutEditText = (EditText) view.findViewById(R.id.connectionTimeoutEditText); mConnectionTimeoutEditText.setText(String.valueOf(mSettings.getConnectionTimeout())); mConnectionTimeoutEditText.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) { } @Override public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) { } @Override public void afterTextChanged(Editable editable) { if (editable.length() > 0) { try { mSettings.setConnectionTimeout(Long.parseLong(editable.toString())); } catch (NumberFormatException e) { Log.e(TAG, e.getMessage(), e); mConnectionTimeoutEditText.setText(String.valueOf(mSettings.getConnectionTimeout())); } } } }); mPortNumberEditText = (EditText) view.findViewById(R.id.portNumberEditText); mPortNumberEditText.setText(String.valueOf(mSettings.getPortNumber())); mPortNumberEditText.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) { } @Override public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) { } @Override public void afterTextChanged(Editable editable) { if (editable.length() > 0 && !editable.toString().equals("-")) { try { mSettings.setPortNumber(Integer.parseInt(editable.toString())); } catch (NumberFormatException e) { Log.e(TAG, e.getMessage(), e); mPortNumberEditText.setText(String.valueOf(mSettings.getPortNumber())); } } } }); mListenForIncomingConnectionsCheckbox = (CheckBox) view .findViewById(R.id.listenForIncomingConnectionCheckbox); mListenForIncomingConnectionsCheckbox.setChecked(mSettings.getListenForIncomingConnections()); mListenForIncomingConnectionsCheckbox .setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean b) { mSettings.setListenForIncomingConnections(b); } }); mHandshakeRequiredCheckbox = (CheckBox) view.findViewById(R.id.handshakeRequiredCheckBox); mHandshakeRequiredCheckbox.setChecked(mSettings.getHandshakeRequired()); mHandshakeRequiredCheckbox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean b) { mSettings.setHandshakeRequired(b); } }); mEnableWifiCheckBox = (CheckBox) view.findViewById(R.id.enableWifiCheckBox); mEnableWifiCheckBox.setChecked(mSettings.getEnableWifiDiscovery()); mEnableWifiCheckBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean b) { mSettings.setEnableWifiDiscovery(b); } }); mEnableBleCheckBox = (CheckBox) view.findViewById(R.id.enableBleCheckBox); mEnableBleCheckBox.setChecked(mSettings.getEnableBleDiscovery()); mEnableBleCheckBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean b) { mSettings.setEnableBleDiscovery(b); } }); Spinner spinner = (Spinner) view.findViewById(R.id.advertiseModeSpinner); ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(view.getContext(), R.array.advertise_mode_string_array, android.R.layout.simple_spinner_item); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner.setAdapter(adapter); spinner.setSelection(mSettings.getAdvertiseMode()); spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> adapterView, View view, int index, long l) { mSettings.setAdvertiseMode(index); } @Override public void onNothingSelected(AdapterView<?> adapterView) { } }); spinner = (Spinner) view.findViewById(R.id.advertiseTxPowerLevelSpinner); adapter = ArrayAdapter.createFromResource(view.getContext(), R.array.advertise_tx_power_level_string_array, android.R.layout.simple_spinner_item); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner.setAdapter(adapter); spinner.setSelection(mSettings.getAdvertiseTxPowerLevel()); spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> adapterView, View view, int index, long l) { mSettings.setAdvertiseTxPowerLevel(index); } @Override public void onNothingSelected(AdapterView<?> adapterView) { } }); spinner = (Spinner) view.findViewById(R.id.scanModeSpinner); adapter = ArrayAdapter.createFromResource(view.getContext(), R.array.scan_mode_string_array, android.R.layout.simple_spinner_item); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner.setAdapter(adapter); spinner.setSelection(mSettings.getScanMode()); spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> adapterView, View view, int index, long l) { mSettings.setScanMode(index); } @Override public void onNothingSelected(AdapterView<?> adapterView) { } }); mBufferSizeEditText = (EditText) view.findViewById(R.id.bufferSizeEditText); mBufferSizeEditText.setText(String.valueOf(mSettings.getBufferSize())); mBufferSizeEditText.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) { } @Override public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) { } @Override public void afterTextChanged(Editable editable) { if (editable.length() > 0) { try { mSettings.setBufferSize(Integer.parseInt(editable.toString())); } catch (NumberFormatException e) { Log.e(TAG, e.getMessage(), e); mBufferSizeEditText.setText(String.valueOf(mSettings.getBufferSize())); } } } }); mDataAmountEditText = (EditText) view.findViewById(R.id.dataAmountEditText); mDataAmountEditText.setText(String.valueOf(mSettings.getDataAmount())); mDataAmountEditText.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) { } @Override public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) { } @Override public void afterTextChanged(Editable editable) { if (editable.length() > 0) { try { mSettings.setDataAmount(Long.parseLong(editable.toString())); } catch (NumberFormatException e) { Log.e(TAG, e.getMessage(), e); mDataAmountEditText.setText(String.valueOf(mSettings.getDataAmount())); } } } }); mEnableAutoConnectCheckBox = (CheckBox) view.findViewById(R.id.autoConnectCheckBox); mEnableAutoConnectCheckBox.setChecked(mSettings.getAutoConnect()); mEnableAutoConnectCheckBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean b) { mSettings.setAutoConnect(b); } }); mEnableAutoConnectEvenWhenIncomingConnectionEstablishedCheckBox = (CheckBox) view .findViewById(R.id.autoConnectEvenWhenIncomingCheckBox); mEnableAutoConnectEvenWhenIncomingConnectionEstablishedCheckBox .setChecked(mSettings.getAutoConnectEvenWhenIncomingConnectionEstablished()); mEnableAutoConnectEvenWhenIncomingConnectionEstablishedCheckBox .setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean b) { mSettings.setAutoConnectEvenWhenIncomingConnectionEstablished(b); } }); return view; }
From source file:org.gnucash.android.ui.account.AccountFormFragment.java
/** * Inflates the dialog view and retrieves references to the dialog elements *//*from ww w . ja v a 2 s . c o m*/ @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_new_account, container, false); getSherlockActivity().getSupportActionBar().setTitle(R.string.title_add_account); mCurrencySpinner = (Spinner) view.findViewById(R.id.input_currency_spinner); mNameEditText = (EditText) view.findViewById(R.id.edit_text_account_name); mNameEditText.requestFocus(); mAccountTypeSpinner = (Spinner) view.findViewById(R.id.input_account_type_spinner); mAccountTypeSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parentView, View selectedItemView, int position, long id) { loadParentAccountList(getSelectedAccountType()); setParentAccountSelection(mParentAccountId); } @Override public void onNothingSelected(AdapterView<?> adapterView) { //nothing to see here, move along } }); mPlaceholderCheckBox = (CheckBox) view.findViewById(R.id.checkbox_placeholder_account); mParentAccountSpinner = (Spinner) view.findViewById(R.id.input_parent_account); mParentAccountSpinner.setEnabled(false); mParentCheckBox = (CheckBox) view.findViewById(R.id.checkbox_parent_account); mParentCheckBox.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { mParentAccountSpinner.setEnabled(isChecked); } }); mDefaulTransferAccountSpinner = (Spinner) view.findViewById(R.id.input_default_transfer_account); mDefaulTransferAccountSpinner.setEnabled(false); mDefaultTransferAccountCheckBox = (CheckBox) view.findViewById(R.id.checkbox_default_transfer_account); mDefaultTransferAccountCheckBox.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean isChecked) { mDefaulTransferAccountSpinner.setEnabled(isChecked); } }); mColorSquare = (ColorSquare) view.findViewById(R.id.input_color_picker); mColorSquare.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { showColorPickerDialog(); } }); return view; }