List of usage examples for android.widget Spinner setAdapter
@Override public void setAdapter(SpinnerAdapter adapter)
From source file:org.catrobat.catroid.content.bricks.BroadcastReceiverBrick.java
@Override public View getView(final Context context, int brickId, BaseAdapter baseAdapter) { if (animationState) { return view; }/* w ww . j a v a 2s .c om*/ if (view == null) { alphaValue = 255; } if (receiveScript == null) { receiveScript = new BroadcastScript(broadcastMessage); MessageContainer.addMessage(getBroadcastMessage()); } view = View.inflate(context, R.layout.brick_broadcast_receive, null); view = getViewWithAlpha(alphaValue); setCheckboxView(R.id.brick_broadcast_receive_checkbox); // XXX method moved to to DragAndDropListView since it is not working on 2.x // checkbox.setOnCheckedChangeListener(new OnCheckedChangeListener() { // // @Override // public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { // checked = isChecked; // if (!checked) { // for (Brick currentBrick : adapter.getCheckedBricks()) { // currentBrick.setCheckedBoolean(false); // } // } // adapter.handleCheck(brickInstance, checked); // } // }); final Spinner broadcastSpinner = (Spinner) view.findViewById(R.id.brick_broadcast_receive_spinner); broadcastSpinner.setFocusableInTouchMode(false); broadcastSpinner.setFocusable(false); if (!(checkbox.getVisibility() == View.VISIBLE)) { broadcastSpinner.setClickable(true); broadcastSpinner.setEnabled(true); } else { broadcastSpinner.setClickable(false); broadcastSpinner.setEnabled(false); } broadcastSpinner.setAdapter(MessageContainer.getMessageAdapter(context)); broadcastSpinner.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { String selectedMessage = broadcastSpinner.getSelectedItem().toString(); if (selectedMessage.equals(context.getString(R.string.new_broadcast_message))) { showNewMessageDialog(broadcastSpinner); } else { receiveScript.setBroadcastMessage(selectedMessage); broadcastMessage = selectedMessage; } } @Override public void onNothingSelected(AdapterView<?> arg0) { } }); setSpinnerSelection(broadcastSpinner); return view; }
From source file:org.thezero.qrfi.SuperAwesomeCardFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final View rootView; if (position == 0) { rootView = inflater.inflate(R.layout.fragment_generate, container, false); final CardView cardQr = (CardView) rootView.findViewById(R.id.card_qr); cardQr.setVisibility(View.GONE); String[] items = new String[] { "Open", "WEP", "WPA/WPA2" }; final EditText ssid = (EditText) rootView.findViewById(R.id.edit_ssid); final EditText pass = (EditText) rootView.findViewById(R.id.edit_pass); final Spinner spinner = (Spinner) rootView.findViewById(R.id.wifi_type); ArrayAdapter<String> adapter = new ArrayAdapter<>(c, android.R.layout.simple_spinner_item, items); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner.setAdapter(adapter); spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override/*from w w w .j a v a 2 s .co m*/ public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { if (parent.getSelectedItem().toString().equals("Open")) { rootView.findViewById(R.id.second).setVisibility(View.GONE); } else { rootView.findViewById(R.id.second).setVisibility(View.VISIBLE); } } @Override public void onNothingSelected(AdapterView<?> parent) { } }); final boolean[] cardHide = { true }; Button delete = (Button) rootView.findViewById(R.id.delete); delete.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { cardHide[0] = true; cardQr.animate().translationY(0).alpha(0.0f).setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); if (cardHide[0]) cardQr.setVisibility(View.GONE); } }); ssid.setText(""); pass.setText(""); spinner.setSelection(0); } }); Button gen = (Button) rootView.findViewById(R.id.generate); gen.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // WIFI:S:Pistol;T:WEP;P:pistolawifi2;; if (pass.getText().length() < 8 && !spinner.getSelectedItem().toString().equals("Open")) { Toast.makeText(c, c.getString(R.string.error_pass), Toast.LENGTH_LONG).show(); return; } String ap = "WIFI:S:" + ssid.getText() + ";T:" + spinner.getSelectedItem().toString() + ";P:" + pass.getText() + ";;"; Log.d(TAG, ap); QRCodeWriter writer = new QRCodeWriter(); try { BitMatrix matrix = writer.encode(ap, BarcodeFormat.QR_CODE, 700, 700, null); int height = matrix.getHeight(); int width = matrix.getWidth(); final Bitmap bmp = Bitmap.createBitmap(width, height, Bitmap.Config.RGB_565); for (int x = 0; x < width; x++) { for (int y = 0; y < height; y++) { bmp.setPixel(x, y, matrix.get(x, y) ? Color.BLACK : Color.WHITE); } } ImageView qr_image = (ImageView) rootView.findViewById(R.id.qrimage); qr_image.setImageBitmap(bmp); cardHide[0] = false; cardQr.setVisibility(View.VISIBLE); cardQr.setAlpha(1.0f); cardQr.animate().translationY(10).alpha(1.0f); Button dialogButton = (Button) rootView.findViewById(R.id.ok); dialogButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { File sdcard = Environment.getExternalStorageDirectory(); FileOutputStream out = null; File check = new File(sdcard, "/wifipv/"); if (!(check.exists())) { boolean resu = check.mkdir(); if (!resu) { return; } } try { File myFile = new File(sdcard, "/wifipv/" + ssid.getText() + ".png"); out = new FileOutputStream(myFile); boolean success = bmp.compress(Bitmap.CompressFormat.PNG, 100, out); if (success) { MediaScannerConnection.scanFile(c, new String[] { myFile.getAbsolutePath() }, null, new MediaScannerConnection.OnScanCompletedListener() { @Override public void onScanCompleted(String path, Uri uri) { Log.d(TAG, "file " + path + " was scanned seccessfully: " + uri); Intent shareIntent = new Intent(); shareIntent.setAction(Intent.ACTION_SEND); shareIntent.putExtra(Intent.EXTRA_STREAM, uri); shareIntent.setType("image/png"); shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); Intent new_intent = Intent.createChooser(shareIntent, c.getText(R.string.send_to)); new_intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); c.startActivity(new_intent); } }); } else { Toast.makeText(c, c.getString(R.string.error_share), Toast.LENGTH_LONG) .show(); } } catch (FileNotFoundException e) { e.printStackTrace(); } finally { if (out != null) try { out.close(); } catch (IOException e) { e.printStackTrace(); } } } }); } catch (WriterException e) { e.printStackTrace(); } } }); } else { rootView = inflater.inflate(R.layout.fragment_scan, container, false); Button scan = (Button) rootView.findViewById(R.id.scan); scan.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent myIntent = new Intent(c, ScanActivity.class); myIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); c.startActivity(myIntent); } }); Button gallery = (Button) rootView.findViewById(R.id.gallery); gallery.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { selectFromGallery(); } }); /*final boolean[] tutorialHide = {false}; final CardView tutorial = (CardView)rootView.findViewById(R.id.card_tutorial); tutorial.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if(tutorialHide[0]){ tutorialHide[0]=false; Animation anidelta = new ResizeAnimation(tutorial, tutorial.getHeight()); anidelta.setDuration(500); anidelta.setFillAfter(true); tutorial.startAnimation(anidelta); }else{ tutorialHide[0]=true; Animation anidelta = new ResizeAnimation(tutorial, 120); anidelta.setDuration(500); anidelta.setFillAfter(true); tutorial.startAnimation(anidelta); } } });*/ } ViewCompat.setElevation(rootView, 50); return rootView; }
From source file:ca.farrelltonsolar.classic.HourLogChart.java
private void setupSpinner(MenuItem item) { try {// w w w . ja v a2 s.c om item.setVisible(true); item.setActionView(R.layout.action_chart_select); View view = MenuItemCompat.getActionView(item); if (view instanceof Spinner) { Spinner spinner = (Spinner) view; String[] itemArray = getResources().getStringArray(R.array.minute_log_chart_selection); ArrayAdapter<String> spinnerArrayAdapter = new ArrayAdapter<String>(this.getActivity(), android.R.layout.simple_spinner_item, itemArray); //selected item will look like a spinner set from XML spinnerArrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner.setAdapter(spinnerArrayAdapter); spinner.setSelection(MonitorApplication.chargeControllers().getCurrentChargeController() .getHourLogMenuSelection(), false); spinner.setOnItemSelectedListener( new OnItemSelectedListenerWrapper(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { chartView.clearSeries(); if (position < mSeries.size()) { MonitorApplication.chargeControllers().getCurrentChargeController() .setHourLogMenuSelection(position); chartView.addSeries(mSeries.get(position)); } } @Override public void onNothingSelected(AdapterView<?> parent) { } })); } } catch (Exception ex) { Log.w(getClass().getName(), String.format("Hour Log Chart failed to load setupSpinner %s ex: %s", Thread.currentThread().getName(), ex)); } }
From source file:uk.org.rivernile.edinburghbustracker.android.fragments.general.AddTimeAlertFragment.java
/** * {@inheritDoc}/*from w w w .j a v a2 s . c o m*/ */ @Override public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) { final View v = inflater.inflate(R.layout.addtimealert, container, false); btnOkay = (Button) v.findViewById(R.id.btnOkay); txtServices = (TextView) v.findViewById(R.id.txtTimeAlertServices); txtTimeDialogStop = (TextView) v.findViewById(R.id.txtTimeDialogStop); btnOkay.setOnClickListener(new OnClickListener() { @Override public void onClick(final View v) { // Add the alert. alertMan.addTimeAlert(stopCode, selectedServices, timeTrigger); // Tell the underlying Activity that a new alert has been added. callbacks.onTimeAlertAdded(); } }); // Set up the spinner. final Spinner spinner = (Spinner) v.findViewById(R.id.time_time_select); final ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(getActivity(), R.array.addtimealert_array, android.R.layout.simple_spinner_item); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner.setAdapter(adapter); spinner.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(final AdapterView<?> parent, final View view, final int pos, final long id) { switch (pos) { case 0: timeTrigger = 1; break; case 1: timeTrigger = 2; break; case 2: timeTrigger = 5; break; case 3: timeTrigger = 10; break; case 4: timeTrigger = 15; break; case 5: timeTrigger = 20; break; case 6: timeTrigger = 25; break; case 7: timeTrigger = 30; break; default: timeTrigger = 0; break; } } @Override public void onNothingSelected(final AdapterView parent) { timeTrigger = 0; } }); Button btn = (Button) v.findViewById(R.id.btnCancel); btn.setOnClickListener(new OnClickListener() { @Override public void onClick(final View v) { // Tell the underlying Activity that the user has cancelled. callbacks.onCancelAddTimeAlert(); } }); btn = (Button) v.findViewById(R.id.btnAlertTimeServices); if (services != null && services.length > 0) { btn.setOnClickListener(new OnClickListener() { @Override public void onClick(final View v) { callbacks.onShowServicesChooser(services, selectedServices, getString(R.string.addtimealert_services_title)); } }); } else { btn.setEnabled(false); } btn = (Button) v.findViewById(R.id.btnLimitations); btn.setOnClickListener(new OnClickListener() { @Override public void onClick(final View v) { callbacks.onShowTimeAlertLimitations(); } }); // Set a piece of informative text with the stopCode, stopName and // locality (if available). final String locality = bsd.getLocalityForStopCode(stopCode); final String name; if (locality != null) { name = getString(R.string.busstop_locality_coloured, bsd.getNameForBusStop(stopCode), locality, stopCode); } else { name = getString(R.string.busstop_coloured, bsd.getNameForBusStop(stopCode), stopCode); } txtTimeDialogStop.setText(Html.fromHtml(getString(R.string.addtimealert_busstop, name))); // Force a refresh of the TextView that shows the services that have // been chosen. onServicesChosen(selectedServices); return v; }
From source file:com.gsma.rcs.provisioning.local.Provisioning.java
private void loadXmlFile() { final boolean logActivated = sLogger.isActivated(); if (logActivated) { sLogger.debug("load XML provisioning File"); }/*from www . j ava 2s.com*/ try { String[] xmlFiles = getProvisioningFiles(); View view = View.inflate(mActivity, R.layout.rcs_provisioning_generate_profile, null); final EditText textEdit = (EditText) view.findViewById(R.id.msisdn); ContactId me = mRcsSettings.getUserProfileImsUserName(); textEdit.setText(me == null ? "" : me.toString()); final Spinner spinner = (Spinner) view.findViewById(R.id.XmlProvisioningFile); ArrayAdapter<String> adapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, xmlFiles); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner.setAdapter(adapter); AlertDialog.Builder builder = new AlertDialog.Builder(this).setTitle(R.string.label_generate_profile) .setView(view).setNegativeButton(R.string.label_cancel, null) .setPositiveButton(R.string.label_ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { ContactUtil.PhoneNumber number = ContactUtil .getValidPhoneNumberFromAndroid(textEdit.getText().toString()); if (number == null) { Toast.makeText(mActivity, getString(R.string.label_load_failed), Toast.LENGTH_LONG) .show(); return; } ContactId contact = ContactUtil.createContactIdFromValidatedData(number); String selectedProvisioningFile = (String) spinner.getSelectedItem(); if (selectedProvisioningFile == null || selectedProvisioningFile.equals(getString(R.string.label_no_xml_file))) { Toast.makeText(mActivity, getString(R.string.label_load_failed), Toast.LENGTH_LONG) .show(); return; } loadProfile(contact, Uri.fromFile(new File(PROVISIONING_FOLDER_PATH, selectedProvisioningFile))); } }); AlertDialog dialog = builder.create(); dialog.setCanceledOnTouchOutside(false); dialog.show(); } catch (SecurityException e) { if (logActivated) { sLogger.warn("Failed to load provisioning file!", e); } } }
From source file:com.renard.ocr.documents.creation.visualisation.LayoutQuestionDialog.java
@NonNull @Override// w ww .j a v a 2s . com public Dialog onCreateDialog(Bundle savedInstanceState) { getAnalytics().sendScreenView(SCREEN_NAME); final Context context = getContext(); mLayout = null; Pair<String, String> language = PreferencesUtils.getOCRLanguage(context); final OcrLanguage.InstallStatus installStatus = OcrLanguageDataStore.isLanguageInstalled(language.first, context); if (!installStatus.isInstalled()) { final String defaultLanguage = context.getString(R.string.default_ocr_language); final String defaultLanguageDisplay = context.getString(R.string.default_ocr_display_language); language = Pair.create(defaultLanguage, defaultLanguageDisplay); } mLanguage = language.first; AlertDialog.Builder builder; builder = new AlertDialog.Builder(context); builder.setCancelable(false); View layout = View.inflate(context, R.layout.dialog_layout_question, null); builder.setView(layout); final ViewFlipper titleViewFlipper = (ViewFlipper) layout.findViewById(R.id.layout_title); final ImageView columnLayout = (ImageView) layout.findViewById(R.id.column_layout); final ImageView pageLayout = (ImageView) layout.findViewById(R.id.page_layout); final ImageSwitcher fairy = (ImageSwitcher) layout.findViewById(R.id.fairy_layout); fairy.setFactory(new ViewSwitcher.ViewFactory() { public View makeView() { return new ImageView(context); } }); fairy.setImageResource(R.drawable.fairy_looks_center); fairy.setInAnimation(context, android.R.anim.fade_in); fairy.setOutAnimation(context, android.R.anim.fade_out); final int color = context.getResources().getColor(R.color.progress_color); final PorterDuffColorFilter colorFilter = new PorterDuffColorFilter(color, PorterDuff.Mode.LIGHTEN); columnLayout.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (mLayout != LayoutKind.COMPLEX) { fairy.setImageResource(R.drawable.fairy_looks_left); titleViewFlipper.setDisplayedChild(2); columnLayout.setColorFilter(colorFilter); pageLayout.clearColorFilter(); mLayout = LayoutKind.COMPLEX; } } }); pageLayout.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (mLayout != LayoutKind.SIMPLE) { mLayout = LayoutKind.SIMPLE; titleViewFlipper.setDisplayedChild(1); fairy.setImageResource(R.drawable.fairy_looks_right); pageLayout.setColorFilter(colorFilter); columnLayout.clearColorFilter(); } } }); final Spinner langButton = (Spinner) layout.findViewById(R.id.button_language); List<OcrLanguage> installedLanguages = OcrLanguageDataStore.getInstalledOCRLanguages(context); // actual values uses by tesseract final ArrayAdapter<OcrLanguage> adapter = new ArrayAdapter<>(context, R.layout.language_spinner_item, installedLanguages); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); langButton.setAdapter(adapter); for (int i = 0; i < installedLanguages.size(); i++) { OcrLanguage lang = installedLanguages.get(i); if (lang.getValue().equals(language.first)) { langButton.setSelection(i, false); break; } } langButton.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { final OcrLanguage item = adapter.getItem(position); mLanguage = item.getValue(); PreferencesUtils.saveOCRLanguage(context, item); getAnalytics().sendOcrLanguageChanged(item); } @Override public void onNothingSelected(AdapterView<?> parent) { } }); builder.setPositiveButton(R.string.start_scan, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { if (mLayout == null) { mLayout = LayoutKind.SIMPLE; } LayoutChoseListener listener = (LayoutChoseListener) getActivity(); listener.onLayoutChosen(mLayout, mLanguage); getAnalytics().sendOcrStarted(mLanguage, mLayout); dialog.dismiss(); } }); builder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { getActivity().finish(); dialog.dismiss(); getAnalytics().sendLayoutDialogCancelled(); } }); return builder.create(); }
From source file:com.z299studio.pb.ActionDialog.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { if (Application.getInstance() == null || Application.getInstance().getAccountManager() == null) { return null; }/*w w w . ja v a 2 s . c om*/ View rootView; int[] layouts = { R.layout.dialog_authenticate, R.layout.dialog_export, R.layout.dialog_import, R.layout.dialog_reset_pwd, R.layout.dialog_credits, R.layout.dialog_license, R.layout.dialog_authenticate }; rootView = inflater.inflate(layouts[mDlgType], container, false); mOkButton = (Button) rootView.findViewById(R.id.ok); if (mOkButton != null) { mOkButton.setOnClickListener(this); } View cancel = rootView.findViewById(R.id.cancel); if (cancel != null) { cancel.setOnClickListener(this); } if (mDlgType != ACTION_EXPORT && mOkButton != null) { mOkButton.setEnabled(false); mOkButton.setAlpha(0.4f); } switch (mDlgType) { case ACTION_EXPORT: case ACTION_IMPORT: Spinner spinner = (Spinner) rootView.findViewById(R.id.spinner); ArrayAdapter<CharSequence> spinnerAdapter = ArrayAdapter.createFromResource(getActivity(), mDlgType == ACTION_EXPORT ? R.array.file_types : R.array.file_types_import, android.R.layout.simple_spinner_dropdown_item); spinner.setAdapter(spinnerAdapter); spinner.setSelection(mFileType); spinner.setOnItemSelectedListener(this); if (mDlgType == ACTION_IMPORT) { int ids[] = { R.id.ignore, R.id.keepall, R.id.overwrite }; for (int i = 0; i < ids.length; ++i) { RadioButton rb = (RadioButton) rootView.findViewById(ids[i]); rb.setOnClickListener(this); if (i == mOption) { rb.setChecked(true); } } mSelectButton = (Button) rootView.findViewById(R.id.select); mSelectButton.setOnClickListener(this); } break; case ACTION_AUTHENTICATE2: ((TextView) rootView.findViewById(R.id.auth_desc)).setText(R.string.diff_pwd); ((Button) rootView.findViewById(R.id.cancel)).setText(R.string.discard); // no break to use the logic of authenticate case ACTION_AUTHENTICATE: mPasswordEdits[1] = (EditText) rootView.findViewById(R.id.et_password); mPasswordEdits[1].addTextChangedListener(this); break; case ACTION_RESET_PWD: int ids[] = { R.id.et_cur_pwd, R.id.et_password, R.id.et_confirm }; for (int i = 0; i < ids.length; ++i) { mPasswordEdits[i] = (EditText) rootView.findViewById(ids[i]); mPasswordEdits[i].addTextChangedListener(this); } break; case ACTION_CREDITS: rootView.findViewById(R.id.cancel).setOnClickListener(this); TextView tv = (TextView) rootView.findViewById(R.id.testers); tv.setText(R.string.cc_yhc); tv = (TextView) rootView.findViewById(R.id.translators); String translators = String.format(Locale.getDefault(), "%s: %s\n%s: %s\n%s: %s", getString(R.string.lang_fr), getString(R.string.cc_xcx), getString(R.string.lang_es), getString(R.string.cc_jh), getString(R.string.lang_zhtw), getString(R.string.cc_qqz)); tv.setText(translators); break; case ACTION_LICENSE: WebView wv = (WebView) rootView.findViewById(R.id.licence_page); wv.loadUrl("file:///android_asset/licence.html"); break; } return rootView; }
From source file:org.irmacard.cardemu.selfenrol.EnrollSelectActivity.java
/** * Called when the user presses the continue button *//*from w w w. j a va 2 s . c om*/ 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.prevas.redmine.NewIssueActivity.java
private void loadContents() { mParentId = getIntent().getIntExtra("Parent", -1); // Parent id if it is a subtask CheckBox parentIdCheckBox = (CheckBox) findViewById(R.id.check_parentId); parentIdCheckBox.setClickable(false); if (-1 != mParentId) { parentIdCheckBox.setChecked(true); parentIdCheckBox.setText("Parent #" + Integer.toString(mParentId)); } else {/*w w w . j ava 2 s .co m*/ parentIdCheckBox.setChecked(false); //parentIdCheckBox.setClickable(false); parentIdCheckBox.setText("No parent"); } mSubjectEditText = (EditText) findViewById(R.id.edit_Subject); mSubjectEditText.setHint("Enter Subject"); mDescriptionEditText = (EditText) findViewById(R.id.edit_Description); //mDescriptionEditText.setHint("Enter Description"); mNotesEditText = (EditText) findViewById(R.id.edit_Notes); mEstimatedHoursEditText = (EditText) findViewById(R.id.edit_EstimatedTime); mStartDateTextView = (TextView) findViewById(R.id.txt_StartDateValue); // Trackers - Spinner Spinner spinTracker = (Spinner) findViewById(R.id.spin_Tracker); try { spinTracker.setAdapter(mTrackerAdapter); } catch (Exception e) { e.printStackTrace(); } // Statuses - Spinner Spinner spinStatus = (Spinner) findViewById(R.id.spin_Status); try { spinStatus.setAdapter(mStatusAdapter); spinStatus.setSelection(mStatusAdapter.getItemIndexByName("New")); } catch (Exception e) { e.printStackTrace(); } // Priority - Spinner Spinner spinPriority = (Spinner) findViewById(R.id.spin_Priority); try { spinPriority.setAdapter(mPrioritiesAdapter); spinPriority.setSelection(mPrioritiesAdapter.getItemIndexByName("Normal")); } catch (Exception e) { e.printStackTrace(); } // Version - Spinner Spinner spinVersion = (Spinner) findViewById(R.id.spin_Version); try { spinVersion.setAdapter(mVersionAdapter); } catch (Exception e) { e.printStackTrace(); } // Assignee Spinner spinMember = (Spinner) findViewById(R.id.spin_Assignee); try { spinMember.setAdapter(mAssigneeAdapter); //String currentUser = PrevasRedmine.m_redmineManager.getCurrentUser().toString(); //spinMember.setSelection(mAssigneeAdapter.getPosition(currentUser)); spinMember.setSelection(mAssigneeAdapter.getPosition("--")); } catch (Exception e) { e.printStackTrace(); } mStartDateBtn = (Button) findViewById(R.id.btn_StartDateChange); mStartDateBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { showDialog(STARTDATE_DIALOG_ID); } }); /* get the current date */ final Calendar startDateCal = Calendar.getInstance(); mStartYear = startDateCal.get(Calendar.YEAR); mStartMonth = startDateCal.get(Calendar.MONTH); mStartDay = startDateCal.get(Calendar.DAY_OF_MONTH); mDueDateTextView = (TextView) findViewById(R.id.txt_DueDateValue); mDueDateBtn = (Button) findViewById(R.id.btn_DueDateChange); mDueDateBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { showDialog(DUEDATE_DIALOG_ID); } }); /* get the current date */ final Calendar dueDateCal = Calendar.getInstance(); mDueYear = dueDateCal.get(Calendar.YEAR); mDueMonth = dueDateCal.get(Calendar.MONTH); mDueDay = dueDateCal.get(Calendar.DAY_OF_MONTH); // Progress Contents mPercentDoneTextView = (TextView) findViewById(R.id.txt_Progress); mPercentDoneSeekbar = (SeekBar) findViewById(R.id.seekbar_PercentDone); try { mPercentDoneTextView.setText("0%"); mPercentDoneSeekbar.setMax(0); mPercentDoneSeekbar.setMax(100); // setting to 0, there is a bug in android progress bar mPercentDoneSeekbar.setProgress(0); mPercentDoneSeekbar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar seekbar, int progress, boolean fromTouch) { mPercentDoneTextView.setText(Integer.toString(progress) + "%"); mPercentDone = progress; } @Override public void onStartTrackingTouch(SeekBar arg0) { } @Override public void onStopTrackingTouch(SeekBar arg0) { } }); } catch (Exception e) { e.printStackTrace(); } }
From source file:it.polimi.spf.app.fragments.profile.ProfileFragment.java
@Override public void onPrepareOptionsMenu(Menu menu) { super.onPrepareOptionsMenu(menu); MenuItem personaSelector = menu.findItem(R.id.profileview_persona_selector); if (personaSelector == null) { return;//from w w w . j av a 2s.c o m } Spinner spinner = (Spinner) personaSelector.getActionView().findViewById(R.id.profileview_persona_spinner); if (spinner == null) { return; } List<SPFPersona> personas = SPF.get().getProfileManager().getAvailablePersonas(); spinner.setAdapter(new ArrayAdapter<SPFPersona>(getActivity().getActionBar().getThemedContext(), android.R.layout.simple_list_item_1, personas)); spinner.setSelection(personas.indexOf(mCurrentPersona), false); spinner.setOnItemSelectedListener(this); }