List of usage examples for android.widget ArrayAdapter setDropDownViewResource
public void setDropDownViewResource(@LayoutRes int resource)
Sets the layout resource to create the drop down views.
From source file:com.akoscz.youtube.YouTubeRecyclerViewFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); // if we have a playlist in our retained fragment, use it to populate the UI if (mPlaylistVideos != null) { // reload the UI with the existing playlist. No need to fetch it again reloadUi(mPlaylistVideos, false); } else {/*from w w w.j a va2 s . c om*/ // otherwise create an empty playlist using the first item in the playlist id's array mPlaylistVideos = new PlaylistVideos(mPlaylistIds[0]); // and reload the UI with the selected playlist and kick off fetching the playlist content reloadUi(mPlaylistVideos, true); } ArrayAdapter<List<String>> spinnerAdapter; // if we don't have the playlist titles yet if (mPlaylistTitles == null || mPlaylistTitles.isEmpty()) { // initialize the spinner with the playlist ID's so that there's something in the UI until the GetPlaylistTitlesAsyncTask finishes spinnerAdapter = new ArrayAdapter(getContext(), SPINNER_ITEM_LAYOUT_ID, Arrays.asList(mPlaylistIds)); } else { // otherwise use the playlist titles for the spinner spinnerAdapter = new ArrayAdapter(getContext(), SPINNER_ITEM_LAYOUT_ID, mPlaylistTitles); } spinnerAdapter.setDropDownViewResource(SPINNER_ITEM_DROPDOWN_LAYOUT_ID); mPlaylistSpinner.setAdapter(spinnerAdapter); // set up the onItemSelectedListener for the spinner mPlaylistSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { // reload the UI with the playlist video list of the selected playlist mPlaylistVideos = new PlaylistVideos(mPlaylistIds[position]); reloadUi(mPlaylistVideos, true); } @Override public void onNothingSelected(AdapterView<?> parent) { } }); }
From source file:com.glanznig.beepme.view.ExportActivity.java
private void populateFields() { BeeperApp app = (BeeperApp) getApplication(); if (app.getPreferences().exportRunningSince() == 0L || (Calendar.getInstance().getTimeInMillis() - app.getPreferences().exportRunningSince()) >= 120000) { //2 min enableDisableView(findViewById(R.id.export_settings), true); CheckBox rawExp = (CheckBox) findViewById(R.id.export_raw); rawExp.setChecked(rawExport);//from w w w.j a v a2s . c o m rawExp.setOnClickListener(this); CheckBox photoExp = (CheckBox) findViewById(R.id.export_photos); View photoExpGroup = findViewById(R.id.export_photos_group); if (PhotoUtils.isEnabled(ExportActivity.this)) { photoExp.setVisibility(View.VISIBLE); photoExpGroup.setVisibility(View.VISIBLE); File[] photos = PhotoUtils.getPhotos(ExportActivity.this); if (photos != null && photos.length > 0) { photoExp.setEnabled(true); photoExp.setChecked(photoExport); photoExp.setOnClickListener(this); enableDisableView(photoExpGroup, photoExport); } else { photoExp.setChecked(false); photoExp.setEnabled(false); enableDisableView(photoExpGroup, false); } downscalePhotos = (Spinner) findViewById(R.id.export_downscale_photos); downscaleAdapter = new ArrayAdapter<CharSequence>(ExportActivity.this, android.R.layout.simple_spinner_item, new ArrayList<CharSequence>()); downscaleAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); downscalePhotos.setAdapter(downscaleAdapter); downscalePhotos.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { densityItem = position; Bundle opts = new Bundle(); opts.putBoolean("photoExport", photoExport); opts.putBoolean("rawExport", rawExport); estimatedSize.setText(String.format(getString(R.string.export_archive_estimated_size), exporter.getReadableArchiveSize(opts, densityFactors.get(downscalePhotos.getSelectedItemPosition()).intValue()))); } @Override public void onNothingSelected(AdapterView<?> parent) { } }); if (photoAvgSize == 0) { File[] photoFiles = PhotoUtils.getPhotos(ExportActivity.this); int count; int overallSize = 0; for (count = 0; count < photoFiles.length; count++) { overallSize += photoFiles[count].length(); } if (count > 0) { photoAvgSize = overallSize / count; } } if (photoAvgDensity == 0) { new Thread(new PhotoDimRunnable(ExportActivity.this, new PhotoDimHandler(ExportActivity.this))) .start(); } else { TextView density = (TextView) findViewById(R.id.export_photos_avg_size); density.setText( getString(R.string.export_photos_avg_size, String.format("%.1f", photoAvgDensity))); downscaleAdapter.add(String.format(getString(R.string.export_downscale_original_size), DataExporter.getReadableFileSize(photoAvgSize, 0))); densityFactors.add(Integer.valueOf(1)); int densityFactor = 2; for (; (Math.round((photoAvgDensity / densityFactor) * 2) / 2f) > 1; densityFactor *= 2) { downscaleAdapter.add(String.format(getString(R.string.export_downscale), String.format("%.1f", Math.round((photoAvgDensity / densityFactor) * 2) / 2f), DataExporter.getReadableFileSize(photoAvgSize / densityFactor, 0))); densityFactors.add(Integer.valueOf(densityFactor)); } downscaleAdapter.add(String.format(getString(R.string.export_downscale), String.valueOf(1), DataExporter.getReadableFileSize(photoAvgSize / densityFactor, 0))); densityFactors.add(Integer.valueOf(densityFactor)); if (densityItem != -1) { downscalePhotos.setSelection(densityItem); } } } else { photoExp.setVisibility(View.GONE); photoExpGroup.setVisibility(View.GONE); } postActions = (Spinner) findViewById(R.id.export_post_actions); ArrayAdapter<CharSequence> actionsAdapter = ArrayAdapter.createFromResource(this, R.array.post_export_actions, android.R.layout.simple_spinner_item); actionsAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); postActions.setAdapter(actionsAdapter); if (postActionItem != -1) { postActions.setSelection(postActionItem); } estimatedSize = (TextView) findViewById(R.id.export_estimated_size); int densityFactor = 1; if (densityFactors.size() > 0 && downscalePhotos.getSelectedItemPosition() >= 0) { densityFactor = densityFactors.get(downscalePhotos.getSelectedItemPosition()).intValue(); } Bundle opts = new Bundle(); opts.putBoolean("photoExport", photoExport); opts.putBoolean("rawExport", rawExport); estimatedSize.setText(String.format(getString(R.string.export_archive_estimated_size), exporter.getReadableArchiveSize(opts, densityFactor))); Button start = (Button) findViewById(R.id.export_start_button); ProgressBar progress = (ProgressBar) findViewById(R.id.export_progress_bar); TextView runningText = (TextView) findViewById(R.id.export_running_text); start.setVisibility(View.VISIBLE); progress.setVisibility(View.GONE); runningText.setVisibility(View.GONE); } else { Button start = (Button) findViewById(R.id.export_start_button); ProgressBar progress = (ProgressBar) findViewById(R.id.export_progress_bar); TextView runningText = (TextView) findViewById(R.id.export_running_text); start.setVisibility(View.GONE); progress.setVisibility(View.VISIBLE); runningText.setVisibility(View.VISIBLE); enableDisableView(findViewById(R.id.export_settings), false); } }
From source file:nl.sogeti.android.gpstracker.actions.ShareTrack.java
private void setGpxExportTargets() { ArrayAdapter<CharSequence> shareTargetAdapter = ArrayAdapter.createFromResource(this, R.array.sharegpxtarget_choices, android.R.layout.simple_spinner_item); shareTargetAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); mShareTargetSpinner.setAdapter(shareTargetAdapter); int lastTarget = PreferenceManager.getDefaultSharedPreferences(this).getInt(Constants.EXPORT_GPXTARGET, EXPORT_TARGET_SEND);//from www .ja v a 2 s . c om mShareTargetSpinner.setSelection(lastTarget); }
From source file:nl.sogeti.android.gpstracker.actions.ShareTrack.java
private void setKmzExportTargets() { ArrayAdapter<CharSequence> shareTargetAdapter = ArrayAdapter.createFromResource(this, R.array.sharekmztarget_choices, android.R.layout.simple_spinner_item); shareTargetAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); mShareTargetSpinner.setAdapter(shareTargetAdapter); int lastTarget = PreferenceManager.getDefaultSharedPreferences(this).getInt(Constants.EXPORT_KMZTARGET, EXPORT_TARGET_SEND);/*from w ww .j av a 2 s .c o m*/ mShareTargetSpinner.setSelection(lastTarget); }
From source file:nl.sogeti.android.gpstracker.actions.ShareTrack.java
private void setTextLineExportTargets() { ArrayAdapter<CharSequence> shareTargetAdapter = ArrayAdapter.createFromResource(this, R.array.sharetexttarget_choices, android.R.layout.simple_spinner_item); shareTargetAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); mShareTargetSpinner.setAdapter(shareTargetAdapter); int lastTarget = PreferenceManager.getDefaultSharedPreferences(this).getInt(Constants.EXPORT_TXTTARGET, EXPORT_TYPE_TWITDRIOD);/* ww w .j ava 2 s .c om*/ mShareTargetSpinner.setSelection(lastTarget); }
From source file:com.mifos.mifosxdroid.online.grouploanaccount.GroupLoanAccountFragment.java
private void inflateInterestCalculationPeriodSpinner(ResponseBody result) { final List<InterestCalculationPeriodType> interestCalculationPeriodType = new ArrayList<>(); // you can use this array to populate your spinner final ArrayList<String> interestCalculationPeriodTypeNames = new ArrayList<String>(); //Try to get response body BufferedReader reader = null; StringBuilder sb = new StringBuilder(); try {/*from w w w. j av a 2s . c o m*/ reader = new BufferedReader(new InputStreamReader(result.byteStream())); String line; while ((line = reader.readLine()) != null) { sb.append(line); } JSONObject obj = new JSONObject(sb.toString()); if (obj.has("interestCalculationPeriodTypeOptions")) { JSONArray interestCalculationPeriodTypes = obj.getJSONArray("interestCalculationPeriodTypeOptions"); for (int i = 0; i < interestCalculationPeriodTypes.length(); i++) { JSONObject interestCalculationPeriodTypeObject = interestCalculationPeriodTypes .getJSONObject(i); InterestCalculationPeriodType interestCalculationPeriod = new InterestCalculationPeriodType(); interestCalculationPeriod.setId(interestCalculationPeriodTypeObject.optInt("id")); interestCalculationPeriod.setValue(interestCalculationPeriodTypeObject.optString("value")); interestCalculationPeriodType.add(interestCalculationPeriod); interestCalculationPeriodTypeNames.add(interestCalculationPeriodTypeObject.optString("value")); interestCalculationPeriodTypeIdHashMap.put(interestCalculationPeriod.getValue(), interestCalculationPeriod.getId()); } } String stringResult = sb.toString(); } catch (Exception e) { Log.e(LOG_TAG, "", e); } final ArrayAdapter<String> interestCalculationPeriodTypeAdapter = new ArrayAdapter<>(getActivity(), layout.simple_spinner_item, interestCalculationPeriodTypeNames); interestCalculationPeriodTypeAdapter.setDropDownViewResource(layout.simple_spinner_dropdown_item); sp_interestcalculationperiod.setAdapter(interestCalculationPeriodTypeAdapter); sp_interestcalculationperiod.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) { interestCalculationPeriodTypeId = interestCalculationPeriodTypeIdHashMap .get(interestCalculationPeriodTypeNames.get(i)); Log.d("interestCalculation " + interestCalculationPeriodTypeNames.get(i), String.valueOf(interestCalculationPeriodTypeId)); if (interestCalculationPeriodTypeId != -1) { } else { Toast.makeText(getActivity(), getString(R.string.error_select_interestCalculationPeriod), Toast.LENGTH_SHORT).show(); } } @Override public void onNothingSelected(AdapterView<?> parent) { } }); }
From source file:com.google.android.apps.forscience.whistlepunk.metadata.EditTriggerFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup parent, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_trigger_edit, parent, false); setHasOptionsMenu(true);// w w w.j a v a2s . c o m mNoteGroup = (ViewGroup) view.findViewById(R.id.note_type_trigger_section); mAlertGroup = (ViewGroup) view.findViewById(R.id.alert_type_trigger_section); mTypeSpinner = (AppCompatSpinner) view.findViewById(R.id.trigger_type_spinner); ArrayAdapter<CharSequence> typeAdapter = ArrayAdapter.createFromResource(getActivity(), R.array.trigger_type_list, android.R.layout.simple_spinner_item); typeAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); mTypeSpinner.setAdapter(typeAdapter); mWhenSpinner = (AppCompatSpinner) view.findViewById(R.id.trigger_when_spinner); ArrayAdapter<CharSequence> whenAdapter = ArrayAdapter.createFromResource(getActivity(), R.array.trigger_when_list, android.R.layout.simple_spinner_item); whenAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); mWhenSpinner.setAdapter(whenAdapter); mValue = (EditText) view.findViewById(R.id.value_input); mNoteValue = (EditText) view.findViewById(R.id.trigger_note_text); mAudioAlert = (CheckBox) view.findViewById(R.id.alert_type_audio_selector); mVisualAlert = (CheckBox) view.findViewById(R.id.alert_type_visual_selector); mHapticAlert = (CheckBox) view.findViewById(R.id.alert_type_haptic_selector); if (!PermissionUtils.permissionIsGranted(getActivity(), Manifest.permission.VIBRATE)) { mHapticAlert.setEnabled(PermissionUtils.canRequestAgain(getActivity(), Manifest.permission.VIBRATE)); } ; TextView unitsTextView = (TextView) view.findViewById(R.id.units); String units = AppSingleton.getInstance(getActivity()).getSensorAppearanceProvider() .getAppearance(mSensorId).getUnits(getActivity()); unitsTextView.setText(units); if (!isNewTrigger()) { // Populate the view with the trigger's data. int actionType = mTriggerToEdit.getActionType(); mValue.setText(mTriggerToEdit.getValueToTrigger().toString()); mTypeSpinner.setSelection(actionType); mWhenSpinner.setSelection(mTriggerToEdit.getTriggerWhen()); if (actionType == TriggerInformation.TRIGGER_ACTION_ALERT) { int[] alertTypes = mTriggerToEdit.getAlertTypes(); for (int i = 0; i < alertTypes.length; i++) { int alertType = alertTypes[i]; if (alertType == TriggerInformation.TRIGGER_ALERT_AUDIO) { mAudioAlert.setChecked(true); } else if (alertType == TriggerInformation.TRIGGER_ALERT_VISUAL) { mVisualAlert.setChecked(true); } else if (alertType == TriggerInformation.TRIGGER_ALERT_PHYSICAL) { mHapticAlert.setChecked(true); } } } else if (actionType == TriggerInformation.TRIGGER_ACTION_NOTE) { mNoteValue.setText(mTriggerToEdit.getNoteText()); } updateViewVisibilities(actionType); // Now add the save listeners if this is an edited trigger (not a new trigger). TextWatcher watcher = new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } @Override public void afterTextChanged(Editable s) { saveTrigger(); } }; mNoteValue.addTextChangedListener(watcher); mValue.addTextChangedListener(watcher); mWhenSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { saveTrigger(); } @Override public void onNothingSelected(AdapterView<?> parent) { } }); CompoundButton.OnCheckedChangeListener checkedChangeListener = new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { saveTrigger(); } }; mAudioAlert.setOnCheckedChangeListener(checkedChangeListener); mVisualAlert.setOnCheckedChangeListener(checkedChangeListener); } else { // Default to an alert spinner that triggers "at" a value, and does a visual alert. mTypeSpinner.setSelection(TriggerInformation.TRIGGER_ACTION_ALERT); mWhenSpinner.setSelection(TriggerInformation.TRIGGER_WHEN_AT); mVisualAlert.setChecked(true); } mWhenSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { // Hide all but alert types if this is a ABOVE or BELOW. if (position == TriggerInformation.TRIGGER_WHEN_ABOVE || position == TriggerInformation.TRIGGER_WHEN_BELOW) { mTypeSpinner.setSelection(TriggerInformation.TRIGGER_ACTION_ALERT); mTypeSpinner.setEnabled(false); updateViewVisibilities(TriggerInformation.TRIGGER_ACTION_ALERT); selectAlertTypeIfNeeded(); } else { mTypeSpinner.setEnabled(true); } if (!isNewTrigger()) { saveTrigger(); } } @Override public void onNothingSelected(AdapterView<?> parent) { } }); mTypeSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { updateViewVisibilities(position); if (position == TriggerInformation.TRIGGER_ACTION_ALERT) { selectAlertTypeIfNeeded(); } if (!isNewTrigger()) { saveTrigger(); } } @Override public void onNothingSelected(AdapterView<?> parent) { } }); mHapticAlert.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { // Don't let them check this checkbox if they deny the vibrate permission. if (!PermissionUtils.tryRequestingPermission(getActivity(), Manifest.permission.VIBRATE, PERMISSION_VIBRATE, true)) { mHapticAlert.setChecked(false); } ; } if (!isNewTrigger()) { saveTrigger(); } } }); return view; }
From source file:com.dmsl.anyplace.SelectBuildingActivity.java
private void setBuildingSpinner(List<BuildingModel> buildings, List<BuildingModelDistance> distance) { if (!buildings.isEmpty()) { mAnyplaceCache.setSpinnerBuildings(buildings); List<String> list = new ArrayList<String>(); if (distance == null) { for (BuildingModel building : buildings) { list.add(building.name); }// w w w . j a va2s. c om } else { for (int i = 0; i < buildings.size(); i++) { double value = distance.get(i).distance; if (value < 1000) { list.add(String.format("[%.0f m] %s", value, buildings.get(i).name)); } else { list.add(String.format("[%.1f km] %s", value / 1000, buildings.get(i).name)); } } } ArrayAdapter<String> spinnerBuildingsAdapter; spinnerBuildingsAdapter = new ArrayAdapter<String>(getBaseContext(), android.R.layout.simple_spinner_item, list); spinnerBuildingsAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinnerBuildings.setAdapter(spinnerBuildingsAdapter); } }
From source file:com.mifos.mifosxdroid.online.grouploanaccount.GroupLoanAccountFragment.java
private void inflatetransactionProcessingStrategySpinner(ResponseBody result) { final List<TransactionProcessingStrategy> transactionProcessingStrategyType = new ArrayList<>(); // you can use this array to populate your spinner final ArrayList<String> transactionProcessingStrategyTypeNames = new ArrayList<String>(); //Try to get response body BufferedReader reader = null; StringBuilder sb = new StringBuilder(); try {//from ww w. j av a 2s. c om reader = new BufferedReader(new InputStreamReader(result.byteStream())); String line; while ((line = reader.readLine()) != null) { sb.append(line); } JSONObject obj = new JSONObject(sb.toString()); if (obj.has("transactionProcessingStrategyOptions")) { JSONArray transactionProcessingStrategyTypes = obj .getJSONArray("transactionProcessingStrategyOptions"); for (int i = 0; i < transactionProcessingStrategyTypes.length(); i++) { JSONObject transactionProcessingStrategyTypeObject = transactionProcessingStrategyTypes .getJSONObject(i); TransactionProcessingStrategy transactionProcessingStrategy = new TransactionProcessingStrategy(); transactionProcessingStrategy.setId(transactionProcessingStrategyTypeObject.optInt("id")); transactionProcessingStrategy .setName(transactionProcessingStrategyTypeObject.optString("name")); transactionProcessingStrategyType.add(transactionProcessingStrategy); transactionProcessingStrategyTypeNames .add(transactionProcessingStrategyTypeObject.optString("name")); transactionProcessingStrategyTypeIdHashMap.put(transactionProcessingStrategy.getName(), transactionProcessingStrategy.getId()); } } String stringResult = sb.toString(); } catch (Exception e) { Log.e(LOG_TAG, "", e); } final ArrayAdapter<String> transactionProcessingStrategyAdapter = new ArrayAdapter<>(getActivity(), layout.simple_spinner_item, transactionProcessingStrategyTypeNames); transactionProcessingStrategyAdapter.setDropDownViewResource(layout.simple_spinner_dropdown_item); sp_repaymentstrategy.setAdapter(transactionProcessingStrategyAdapter); sp_repaymentstrategy.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) { transactionProcessingStrategyId = transactionProcessingStrategyTypeIdHashMap .get(transactionProcessingStrategyTypeNames.get(i)); Log.d("transactionProcessing " + transactionProcessingStrategyTypeNames.get(i), String.valueOf(transactionProcessingStrategyId)); if (transactionProcessingStrategyId != -1) { } else { Toast.makeText(getActivity(), getString(R.string.error_select_transactionProcessingStrategy), Toast.LENGTH_SHORT).show(); } } @Override public void onNothingSelected(AdapterView<?> parent) { } }); }
From source file:com.vkassin.mtrade.Common.java
public static void putOrder(final Context ctx, Quote quote) { final Instrument it = Common.selectedInstrument;// adapter.getItem(selectedRowId); final Dialog dialog = new Dialog(ctx); dialog.setContentView(R.layout.order_dialog); dialog.setTitle(R.string.OrderDialogTitle); datetxt = (EditText) dialog.findViewById(R.id.expdateedit); SimpleDateFormat sdf = new SimpleDateFormat("dd.MM.yyyy"); Date dat1 = new Date(); datetxt.setText(sdf.format(dat1));/*w w w .j a va 2 s . c o m*/ mYear = dat1.getYear() + 1900; mMonth = dat1.getMonth(); mDay = dat1.getDate(); final Date dat = new GregorianCalendar(mYear, mMonth, mDay).getTime(); datetxt.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { Log.i(TAG, "Show DatePickerDialog"); DatePickerDialog dpd = new DatePickerDialog(ctx, mDateSetListener, mYear, mMonth, mDay); dpd.show(); } }); TextView itext = (TextView) dialog.findViewById(R.id.instrtext); itext.setText(it.symbol); final Spinner aspinner = (Spinner) dialog.findViewById(R.id.acc_spinner); List<String> list = new ArrayList<String>(Common.getAccountList()); ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>(Common.app_ctx, android.R.layout.simple_spinner_item, list); dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_item); aspinner.setAdapter(dataAdapter); final EditText pricetxt = (EditText) dialog.findViewById(R.id.priceedit); final EditText quanttxt = (EditText) dialog.findViewById(R.id.quantedit); final Button buttonpm = (Button) dialog.findViewById(R.id.buttonPriceMinus); buttonpm.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { try { double price = Double.valueOf(pricetxt.getText().toString()); price -= 0.01; if (price < 0) price = 0; pricetxt.setText(twoDForm.format(price)); } catch (Exception e) { Toast.makeText(ctx, R.string.CorrectPrice, Toast.LENGTH_SHORT).show(); } } }); final Button buttonpp = (Button) dialog.findViewById(R.id.buttonPricePlus); buttonpp.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { try { double price = Double.valueOf(pricetxt.getText().toString()); price += 0.01; pricetxt.setText(twoDForm.format(price)); } catch (Exception e) { Toast.makeText(ctx, R.string.CorrectPrice, Toast.LENGTH_SHORT).show(); } } }); final Button buttonqm = (Button) dialog.findViewById(R.id.buttonQtyMinus); buttonqm.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { try { long qty = Long.valueOf(quanttxt.getText().toString()); qty -= 1; if (qty < 0) qty = 0; quanttxt.setText(String.valueOf(qty)); } catch (Exception e) { Toast.makeText(ctx, R.string.CorrectQty, Toast.LENGTH_SHORT).show(); } } }); final Button buttonqp = (Button) dialog.findViewById(R.id.buttonQtyPlus); buttonqp.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { try { long qty = Long.valueOf(quanttxt.getText().toString()); qty += 1; quanttxt.setText(String.valueOf(qty)); } catch (Exception e) { Toast.makeText(ctx, R.string.CorrectQty, Toast.LENGTH_SHORT).show(); } } }); final RadioButton bu0 = (RadioButton) dialog.findViewById(R.id.radio0); final RadioButton bu1 = (RadioButton) dialog.findViewById(R.id.radio1); if (quote != null) { // pricetxt.setText(quote.price.toString()); pricetxt.setText(quote.getPriceS()); if (quote.qtyBuy > 0) { quanttxt.setText(quote.qtyBuy.toString()); bu1.setChecked(true); bu0.setChecked(false); } else { quanttxt.setText(quote.qtySell.toString()); bu1.setChecked(false); bu0.setChecked(true); } } Button customDialog_Cancel = (Button) dialog.findViewById(R.id.cancelbutt); customDialog_Cancel.setOnClickListener(new Button.OnClickListener() { public void onClick(View arg0) { dialog.dismiss(); } }); Button customDialog_Put = (Button) dialog.findViewById(R.id.putorder); customDialog_Put.setOnClickListener(new Button.OnClickListener() { public void onClick(View arg0) { Double price = new Double(0); Long qval = new Long(0); try { price = Double.valueOf(pricetxt.getText().toString()); } catch (Exception e) { Toast.makeText(ctx, R.string.CorrectPrice, Toast.LENGTH_SHORT).show(); return; } try { qval = Long.valueOf(quanttxt.getText().toString()); } catch (Exception e) { Toast.makeText(ctx, R.string.CorrectQty, Toast.LENGTH_SHORT).show(); return; } if (dat.compareTo(new GregorianCalendar(mYear, mMonth, mDay).getTime()) > 0) { Toast.makeText(ctx, R.string.CorrectDate, Toast.LENGTH_SHORT).show(); return; } JSONObject msg = new JSONObject(); try { msg.put("objType", Common.CREATE_REMOVE_ORDER); msg.put("time", Calendar.getInstance().getTimeInMillis()); msg.put("version", Common.PROTOCOL_VERSION); msg.put("device", "Android"); msg.put("instrumId", Long.valueOf(it.id)); msg.put("price", price); msg.put("qty", qval); msg.put("ordType", 1); msg.put("side", bu0.isChecked() ? 0 : 1); msg.put("code", String.valueOf(aspinner.getSelectedItem())); msg.put("orderNum", ++ordernum); msg.put("action", "CREATE"); boolean b = (((mYear - 1900) == dat.getYear()) && (mMonth == dat.getMonth()) && (mDay == dat.getDate())); if (!b) msg.put("expired", String.format("%02d.%02d.%04d", mDay, mMonth + 1, mYear)); if (isSSL) { // ? ?: newOrder-orderNum-instrumId-side-price-qty-code-ordType // : newOrder-16807-20594623-0-1150-13-1027700451-1 String forsign = "newOrder-" + ordernum + "-" + msg.getString("instrumId") + "-" + msg.getString("side") + "-" + JSONObject.numberToString(Double.valueOf(msg.getDouble("price"))) + "-" + msg.getString("qty") + "-" + msg.getString("code") + "-" + msg.getString("ordType"); byte[] signed = Common.signText(Common.signProfile, forsign.getBytes(), true); String gsign = Base64.encodeToString(signed, Base64.DEFAULT); msg.put("gostSign", gsign); } mainActivity.writeJSONMsg(msg); } catch (Exception e) { e.printStackTrace(); Log.e(TAG, "Error! Cannot create JSON order object", e); } dialog.dismiss(); } }); dialog.show(); WindowManager.LayoutParams lp = new WindowManager.LayoutParams(); lp.copyFrom(dialog.getWindow().getAttributes()); lp.width = WindowManager.LayoutParams.FILL_PARENT; lp.height = WindowManager.LayoutParams.FILL_PARENT; dialog.getWindow().setAttributes(lp); }