List of usage examples for android.text InputType TYPE_CLASS_NUMBER
int TYPE_CLASS_NUMBER
To view the source code for android.text InputType TYPE_CLASS_NUMBER.
Click Source Link
From source file:org.openmrs.mobile.activities.formdisplay.FormDisplayPageFragment.java
@Override public void createAndAttachNumericQuestionEditText(Question question, LinearLayout sectionLinearLayout) { LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); RangeEditText ed = new RangeEditText(getActivity()); ed.setName(question.getLabel());/* w w w . j ava2 s.co m*/ ed.setSingleLine(true); if (question.getQuestionOptions().getMax() != null) { ed.setHint(" [" + question.getQuestionOptions().getMin() + "-" + question.getQuestionOptions().getMax() + "]"); ed.setUpperlimit(Double.parseDouble(question.getQuestionOptions().getMax())); ed.setLowerlimit(Double.parseDouble(question.getQuestionOptions().getMin())); } else { ed.setHint(question.getLabel()); ed.setLowerlimit(-1.0); ed.setUpperlimit(-1.0); } ed.setTextSize(TypedValue.COMPLEX_UNIT_SP, 16); if (question.getQuestionOptions().isAllowDecimal()) { ed.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL); } else { ed.setInputType(InputType.TYPE_CLASS_NUMBER); } InputField field = new InputField(question.getQuestionOptions().getConcept()); ed.setId(field.getId()); InputField inputField = getInputField(field.getConcept()); if (inputField != null) { inputField.setId(field.getId()); Double value = inputField.getValue(); if (-1.0 != value) ed.setText(value.toString()); } else { field.setConcept(question.getQuestionOptions().getConcept()); inputFields.add(field); } sectionLinearLayout.addView(generateTextView(question.getLabel())); sectionLinearLayout.addView(ed, layoutParams); }
From source file:tinygsn.gui.android.ActivityViewData.java
private void addTableViewModeLatest() { table_view_mode = (TableLayout) findViewById(R.id.table_view_mode); // table_view_mode.setLayoutParams(new // TableLayout.LayoutParams(LayoutParams.FILL_PARENT, // LayoutParams.WRAP_CONTENT)); table_view_mode.removeAllViews();//from w w w .j av a2s . co m TableRow row = new TableRow(this); TextView txt = new TextView(this); txt.setText(" View "); txt.setTextColor(Color.parseColor("#000000")); row.addView(txt); final EditText editText_numLatest = new EditText(this); editText_numLatest.setText("10"); editText_numLatest.setInputType(InputType.TYPE_CLASS_NUMBER); editText_numLatest.requestFocus(); editText_numLatest.setTextColor(Color.parseColor("#000000")); row.addView(editText_numLatest); editText_numLatest.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void afterTextChanged(Editable s) { try { numLatest = Integer.parseInt(editText_numLatest.getText().toString()); loadLatestData(); } catch (NumberFormatException e) { AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(context); alertDialogBuilder.setTitle("Please input a number!"); } } }); txt = new TextView(this); txt.setText(" latest values"); txt.setTextColor(Color.parseColor("#000000")); row.addView(txt); txt = new TextView(this); txt.setText(" "); row.addView(txt); table_view_mode.addView(row); row = new TableRow(this); Button detailBtn = new Button(this); // plotDataBtn.setTextSize(TEXT_SIZE); detailBtn.setText("Detail"); detailBtn.setTextColor(Color.parseColor("#000000")); detailBtn.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // Toast.makeText(context, "detailBtn is clicked", // Toast.LENGTH_SHORT).show(); showDialogDetail(); } }); Button plotDataBtn = new Button(this); // plotDataBtn.setTextSize(TEXT_SIZE); plotDataBtn.setText("Plot data"); plotDataBtn.setTextColor(Color.parseColor("#000000")); plotDataBtn.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { viewChart(); } }); TableRow.LayoutParams params = new TableRow.LayoutParams(); // params.addRule(TableRow.LayoutParams.FILL_PARENT); params.span = 2; row.addView(detailBtn, params); row.addView(plotDataBtn, params); row.setLayoutParams(new TableLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); table_view_mode.addView(row); }
From source file:ch.hearc.drunksum.DrunkSumActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { /*/*from w w w . j a va 2 s.c om*/ Gre le clic sur un lment du menu */ if (item.getItemId() == R.id.reinit) { // remet la somme 0 Toast.makeText(this, "Sum reinitialized", Toast.LENGTH_SHORT).show(); mSum = 0; setTitle("Sum: " + formatter.format(mSum)); } else if (item.getItemId() == R.id.divide) { // propose de divisier la somme AlertDialog.Builder alert = new AlertDialog.Builder(this); alert.setTitle("Divide sum by:"); final EditText input = new EditText(this); // n'afficher que les chiffres input.setInputType(InputType.TYPE_CLASS_NUMBER); alert.setView(input); alert.setPositiveButton("Divide", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { double div = 0; try { // une exception survient si le texte est vide // si c'est 0, div vaut infinity div = mSum / Double.parseDouble(input.getText().toString()); } catch (Exception e) { } final Snackbar snackBar = Snackbar.make(mGraphicOverlay, "Divided sum: " + formatter.format(div), Snackbar.LENGTH_INDEFINITE); snackBar.setAction("OK", new View.OnClickListener() { @Override public void onClick(View v) { snackBar.dismiss(); } }); snackBar.show(); } }); alert.show(); } return true; }
From source file:org.asnelt.derandom.MainActivity.java
/** * Initializes this activity and eventually recovers its state. * @param savedInstanceState Bundle with saved state *///from www .j a va2 s . co m @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); PreferenceManager.setDefaultValues(this, R.xml.preferences, false); textHistoryInput = (HistoryView) findViewById(R.id.text_history_input); textHistoryInput.setHistoryViewListener(this); textHistoryPrediction = (HistoryView) findViewById(R.id.text_history_prediction); textHistoryPrediction.setHistoryViewListener(this); textPrediction = (TextView) findViewById(R.id.text_prediction); textInput = (EditText) findViewById(R.id.text_input); spinnerInput = (Spinner) findViewById(R.id.spinner_input); spinnerGenerator = (Spinner) findViewById(R.id.spinner_generator); progressBar = (ProgressBar) findViewById(R.id.progress_bar); textInput.setRawInputType(InputType.TYPE_CLASS_NUMBER); textHistoryInput.setHorizontallyScrolling(true); textHistoryPrediction.setHorizontallyScrolling(true); textPrediction.setHorizontallyScrolling(true); textHistoryInput.setMovementMethod(new ScrollingMovementMethod()); textHistoryPrediction.setMovementMethod(new ScrollingMovementMethod()); textPrediction.setMovementMethod(new ScrollingMovementMethod()); ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { actionBar.setDisplayShowHomeEnabled(true); actionBar.setIcon(R.drawable.ic_launcher); } FragmentManager fragmentManager = getSupportFragmentManager(); processingFragment = (ProcessingFragment) fragmentManager.findFragmentByTag(TAG_PROCESSING_FRAGMENT); // Generate new fragment if there is no retained fragment if (processingFragment == null) { processingFragment = new ProcessingFragment(); fragmentManager.beginTransaction().add(processingFragment, TAG_PROCESSING_FRAGMENT).commit(); } // Apply predictions length preference int predictionLength = getNumberPreference(SettingsActivity.KEY_PREF_PREDICTION_LENGTH); processingFragment.setPredictionLength(predictionLength); // Apply server port preference int serverPort = getNumberPreference(SettingsActivity.KEY_PREF_SOCKET_PORT); processingFragment.setServerPort(serverPort); // Apply history length preference int historyLength = getNumberPreference(SettingsActivity.KEY_PREF_HISTORY_LENGTH); textHistoryInput.setCapacity(historyLength); textHistoryPrediction.setCapacity(historyLength); processingFragment.setCapacity(historyLength); // Apply color preference SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this); if (sharedPreferences.getBoolean(SettingsActivity.KEY_PREF_COLORED_PAST, true)) { textHistoryPrediction.enableColor(null); } // Apply auto-detect preference boolean autoDetect = sharedPreferences.getBoolean(SettingsActivity.KEY_PREF_AUTO_DETECT, true); processingFragment.setAutoDetect(autoDetect); // Eventually recover state if (savedInstanceState != null) { Layout layout = textHistoryInput.getLayout(); if (layout != null) { textHistoryInput.scrollTo(0, layout.getHeight()); } layout = textHistoryPrediction.getLayout(); if (layout != null) { textHistoryPrediction.scrollTo(0, layout.getHeight()); } textPrediction.scrollTo(0, 0); Uri inputUri = processingFragment.getInputUri(); if (inputUri != null) { disableDirectInput(inputUri); } if (processingFragment.getInputSelection() == INDEX_SOCKET_INPUT) { disableDirectInput(null); } } // Create an ArrayAdapter using the string array and a default spinner layout String[] inputNames = new String[3]; inputNames[INDEX_DIRECT_INPUT] = getResources().getString(R.string.input_direct_name); inputNames[INDEX_FILE_INPUT] = getResources().getString(R.string.input_file_name); inputNames[INDEX_SOCKET_INPUT] = getResources().getString(R.string.input_socket_name); ArrayAdapter<String> spinnerInputAdapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, inputNames); // Specify the layout to use when the list of choices appears spinnerInputAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); // Apply the adapter to the spinner spinnerInput.setAdapter(spinnerInputAdapter); spinnerInput.setOnItemSelectedListener(this); if (spinnerInput.getSelectedItemPosition() != processingFragment.getInputSelection()) { spinnerInput.setSelection(processingFragment.getInputSelection()); } // Create an ArrayAdapter using the string array and a default spinner layout String[] generatorNames = processingFragment.getGeneratorNames(); ArrayAdapter<String> spinnerGeneratorAdapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, generatorNames); // Specify the layout to use when the list of choices appears spinnerGeneratorAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); // Apply the adapter to the spinner spinnerGenerator.setAdapter(spinnerGeneratorAdapter); spinnerGenerator.setOnItemSelectedListener(this); if (processingFragment.isMissingUpdate()) { // The activity missed an update while it was reconstructed processingFragment.updateAll(); } onProgressUpdate(); }
From source file:net.bytten.comicviewer.ComicViewerActivity.java
protected void resetContent() { comicDef = makeComicDef();/*from w w w. j av a 2 s . co m*/ provider = comicDef.getProvider(); comicInfo = provider.createEmptyComicInfo(); //Only hide the title bar if we're running an android less than Android 3.0 if (VersionHacks.getSdkInt() < 11) requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.main); webview = (HackedWebView) findViewById(R.id.viewer); title = (TextView) findViewById(R.id.title); comicIdSel = (EditText) findViewById(R.id.comicIdSel); webview.requestFocus(); zoom = webview.getZoomControls(); webview.setClickable(true); webview.setOnClickListener(new OnClickListener() { public void onClick(View v) { if (!"".equals(comicInfo.getAlt())) showDialog(DIALOG_SHOW_HOVER_TEXT); } }); title.setText(comicInfo.getTitle()); comicIdSel.setText(comicInfo.getId()); if (comicDef.idsAreNumbers()) comicIdSel.setInputType(InputType.TYPE_CLASS_NUMBER); comicIdSel.setOnEditorActionListener(new OnEditorActionListener() { public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { String text = comicIdSel.getText().toString(); if (!text.equals("") && (actionId == EditorInfo.IME_ACTION_GO || (actionId == EditorInfo.IME_NULL && event.getKeyCode() == KeyEvent.KEYCODE_ENTER))) { loadComic(createComicUri(text)); comicIdSel.setText(""); return true; } return false; } }); comicIdSel.setOnFocusChangeListener(new OnFocusChangeListener() { public void onFocusChange(View v, boolean hasFocus) { InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); if (hasFocus) { comicIdSel.setText(""); imm.showSoftInput(comicIdSel, InputMethodManager.SHOW_IMPLICIT); } else { imm.hideSoftInputFromWindow(comicIdSel.getWindowToken(), 0); } } }); ((Button) findViewById(R.id.firstBtn)).setOnClickListener(new View.OnClickListener() { public void onClick(View v) { goToFirst(); } }); ((Button) findViewById(R.id.prevBtn)).setOnClickListener(new View.OnClickListener() { public void onClick(View v) { goToPrev(); } }); ((Button) findViewById(R.id.nextBtn)).setOnClickListener(new View.OnClickListener() { public void onClick(View v) { goToNext(); } }); ((Button) findViewById(R.id.finalBtn)).setOnClickListener(new View.OnClickListener() { public void onClick(View v) { goToFinal(); } }); ((ImageView) findViewById(R.id.randomBtn)).setOnClickListener(new View.OnClickListener() { public void onClick(View v) { goToRandom(); } }); bookmarkBtn = (ImageView) findViewById(R.id.bookmarkBtn); bookmarkBtn.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { toggleBookmark(); } }); refreshBookmarkBtn(); }
From source file:org.cafemember.messenger.mytg.fragments.TransfareActivity.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { context = getContext();/*from ww w .jav a 2 s .com*/ // View layout = inflater.inflate(R.layout.channels_layout, null); /*this.context = context; actionBar.setBackButtonImage(R.drawable.ic_ab_back); actionBar.setAllowOverlayTitle(true); actionBar.setTitle(LocaleController.getString("MenuTransfare", R.string.MenuTransfare)); actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() { @Override public void onItemClick(int id) { if (id == -1) { finishFragment(); } else if (id == done_button) { saveName(); }else if (id == contact_button) { getContacts(); } } }); ActionBarMenu menu = actionBar.createMenu(); contactsButton = menu.addItemWithWidth(contact_button, R.drawable.user_profile, AndroidUtilities.dp(56)); doneButton = menu.addItemWithWidth(done_button, R.drawable.ic_done, AndroidUtilities.dp(56)); */ LinearLayout fragmentView = new LinearLayout(context); ((LinearLayout) fragmentView).setOrientation(LinearLayout.VERTICAL); fragmentView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { return true; } }); TextView ruleTextView = new TextView(context); ruleTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15); ruleTextView.setTextColor(0xff212121); ruleTextView.setGravity(Gravity.RIGHT); // ruleTextView.setText(AndroidUtilities.replaceTags(LocaleController.getString("ShareText", R.string.ShareText))); ruleTextView.setText(LocaleController.getString("transfare_rule", R.string.transfare_rule)); ((LinearLayout) fragmentView).addView(ruleTextView, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER, 24, 10, 24, 30)); phoneField = new EditText(context); phoneField.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18); phoneField.setHintTextColor(0xff979797); phoneField.setTextColor(0xff212121); phoneField.setMaxLines(1); phoneField.setLines(1); phoneField.setGravity(Gravity.RIGHT); phoneField.setPadding(0, 0, 0, 0); phoneField.setSingleLine(true); phoneField.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT); phoneField.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_TEXT_FLAG_MULTI_LINE | InputType.TYPE_TEXT_FLAG_AUTO_CORRECT); phoneField.setImeOptions(EditorInfo.IME_ACTION_DONE); phoneField.setHint(LocaleController.getString("TransfareUserHint", R.string.TransfareUserHint)); AndroidUtilities.clearCursorDrawable(phoneField); amountField = new EditText(context); amountField.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18); amountField.setHintTextColor(0xff979797); amountField.setTextColor(0xff212121); amountField.setMaxLines(1); amountField.setGravity(Gravity.RIGHT); amountField.setLines(1); amountField.setPadding(0, 0, 0, 0); amountField.setSingleLine(true); amountField.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT); amountField.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_TEXT_FLAG_MULTI_LINE | InputType.TYPE_TEXT_FLAG_AUTO_CORRECT); amountField.setImeOptions(EditorInfo.IME_ACTION_DONE); amountField.setHint(LocaleController.getString("TransfareAmountHint", R.string.TransfareAmountHint)); AndroidUtilities.clearCursorDrawable(amountField); phoneField.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) { if (i == EditorInfo.IME_ACTION_DONE && doneButton != null) { doneButton.performClick(); return true; } return false; } }); ((LinearLayout) fragmentView).addView(phoneField, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 36, 24, 24, 24, 0)); checkTextView = new TextView(context); checkTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15); checkTextView.setGravity(Gravity.RIGHT); ((LinearLayout) fragmentView).addView(checkTextView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT, 24, 12, 24, 0)); Button button = new Button(context); button.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15); button.setTextColor(0xff6d6d72); button.setGravity(Gravity.CENTER); TextView helpTextView = new TextView(context); helpTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15); helpTextView.setTextColor(0xff6d6d72); helpTextView.setGravity(Gravity.RIGHT); helpTextView.setText(AndroidUtilities.replaceTags(LocaleController.getString("RefHelp", R.string.RefHelp))); button.setText(""); button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { saveName(); } }); ((LinearLayout) fragmentView).addView(helpTextView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT, 24, 10, 24, 0)); ((LinearLayout) fragmentView).addView(amountField, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 36, 24, 24, 24, 0)); ((LinearLayout) fragmentView).addView(button, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, 24, 24, 24, 0)); /*View v = LayoutInflater.from(context).inflate(R.layout.transfare_type, null); typeJoin = (RadioButton)v.findViewById(R.id.joinRadio); typeView = (RadioButton)v.findViewById(R.id.viewRadio); ((LinearLayout) fragmentView).addView(v, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 36, 24, 24, 24, 0));*/ phoneField.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) { } @Override public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) { checkUserName(phoneField.getText().toString(), false); } @Override public void afterTextChanged(Editable editable) { } }); checkTextView.setVisibility(View.GONE); FontManager.instance().setTypefaceImmediate(fragmentView); return fragmentView; }
From source file:net.alexjf.tmm.fragments.ImmedTransactionEditorFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.fragment_immedtransaction_editor, container, false); descriptionText = (EditText) v.findViewById(R.id.description_text); categoryButton = (SelectorButton) v.findViewById(R.id.category_button); executionDateButton = (Button) v.findViewById(R.id.executionDate_button); executionTimeButton = (Button) v.findViewById(R.id.executionTime_button); valueSignToggle = (SignToggleButton) v.findViewById(R.id.value_sign); valueText = (EditText) v.findViewById(R.id.value_text); currencyTextView = (TextView) v.findViewById(R.id.currency_label); transferCheck = (CheckBox) v.findViewById(R.id.transfer_check); transferPanel = (LinearLayout) v.findViewById(R.id.transfer_panel); transferMoneyNodeLabel = (TextView) v.findViewById(R.id.transfer_moneynode_label); transferMoneyNodeButton = (SelectorButton) v.findViewById(R.id.transfer_moneynode_button); transferConversionPanel = (LinearLayout) v.findViewById(R.id.transfer_conversion_panel); transferConversionAmountText = (EditText) v.findViewById(R.id.transfer_conversion_amount_value); transferConversionCurrencyLabel = (TextView) v.findViewById(R.id.transfer_conversion_amount_currency); addButton = (Button) v.findViewById(R.id.add_button); valueText.setRawInputType(InputType.TYPE_CLASS_NUMBER); FragmentManager fm = getFragmentManager(); timePicker = (TimePickerFragment) fm.findFragmentByTag(TAG_TIMEPICKER); datePicker = (DatePickerFragment) fm.findFragmentByTag(TAG_DATEPICKER); if (timePicker == null) { timePicker = new TimePickerFragment(); }//from w w w.ja v a 2s. co m if (datePicker == null) { datePicker = new DatePickerFragment(); } timePicker.setListener(this); datePicker.setListener(this); categoryButton.setOnClickListener(new OnClickListener() { public void onClick(View view) { Intent intent = new Intent(view.getContext(), CategoryListActivity.class); intent.putExtra(CategoryListActivity.KEY_INTENTION, CategoryListActivity.INTENTION_SELECT); startActivityForResult(intent, REQCODE_CATEGORYCHOOSE); } }); executionDateButton.setOnClickListener(new OnClickListener() { public void onClick(View view) { try { datePicker.setDate(dateFormat.parse(executionDateButton.getText().toString())); } catch (ParseException e) { } datePicker.show(getFragmentManager(), TAG_DATEPICKER); } }); executionTimeButton.setOnClickListener(new OnClickListener() { public void onClick(View view) { try { timePicker.setTime(timeFormat.parse(executionTimeButton.getText().toString())); } catch (ParseException e) { } timePicker.show(getFragmentManager(), TAG_TIMEPICKER); } }); valueSignToggle.setOnChangeListener(new SignToggleButton.SignToggleButtonListener() { @Override public void onChange(boolean isPositive) { if (isPositive) { transferMoneyNodeLabel.setText(getResources().getString(R.string.transfer_moneynode_from)); } else { transferMoneyNodeLabel.setText(getResources().getString(R.string.transfer_moneynode_to)); } } }); transferCheck.setOnCheckedChangeListener(new OnCheckedChangeListener() { public void onCheckedChanged(CompoundButton view, boolean checked) { if (checked) { transferPanel.setVisibility(View.VISIBLE); } else { transferPanel.setVisibility(View.GONE); } } ; }); transferMoneyNodeButton.setOnClickListener(new OnClickListener() { public void onClick(View view) { Intent intent = new Intent(view.getContext(), MoneyNodeListActivity.class); intent.putExtra(MoneyNodeListActivity.KEY_INTENTION, MoneyNodeListActivity.INTENTION_SELECT); ArrayList<MoneyNode> excludedMoneyNodes = new ArrayList<MoneyNode>(); excludedMoneyNodes.add(currentMoneyNode); intent.putParcelableArrayListExtra(MoneyNodeListActivity.KEY_EXCLUDE, excludedMoneyNodes); startActivityForResult(intent, REQCODE_MONEYNODECHOOSE); } }); addButton.setOnClickListener(new OnClickListener() { public void onClick(View view) { if (!validateInputFields()) { return; } String description = descriptionText.getText().toString().trim(); boolean isTransfer = transferCheck.isChecked(); Date executionDate; Date executionTime; Date executionDateTime; try { executionDate = dateFormat.parse(executionDateButton.getText().toString()); executionTime = timeFormat.parse(executionTimeButton.getText().toString()); } catch (ParseException e) { executionTime = executionDate = new Date(); } executionDateTime = Utils.combineDateTime(executionDate, executionTime); Money value; try { Calculable calc = new ExpressionBuilder(valueText.getText().toString()).build(); value = Money.of(currentMoneyNode.getCurrency(), calc.calculate(), RoundingMode.HALF_EVEN); } catch (Exception e) { Log.e("TMM", "Error calculating value expression: " + e.getMessage(), e); value = Money.zero(currentMoneyNode.getCurrency()); } if (valueSignToggle.isNegative()) { value = value.negated(); } Money currencyConversionValue = null; // If an amount was entered for conversion to other currency, set // value of transfer transaction to this amount if (isTransfer && !TextUtils.isEmpty(transferConversionAmountText.getText())) { try { Calculable calc = new ExpressionBuilder(transferConversionAmountText.getText().toString()) .build(); currencyConversionValue = Money.of(selectedTransferMoneyNode.getCurrency(), calc.calculate(), RoundingMode.HALF_EVEN); currencyConversionValue = currencyConversionValue.abs(); } catch (Exception e) { Log.e("TMM", "Error calculating conversion amount expression: " + e.getMessage(), e); currencyConversionValue = Money.zero(selectedTransferMoneyNode.getCurrency()); } if (!valueSignToggle.isNegative()) { currencyConversionValue = currencyConversionValue.negated(); } } // If we are creating a new transaction if (transaction == null) { ImmediateTransaction newTransaction = new ImmediateTransaction(currentMoneyNode, value, description, selectedCategory, executionDateTime); // If this new transaction is a transfer if (isTransfer && selectedTransferMoneyNode != null) { ImmediateTransaction otherTransaction = new ImmediateTransaction(newTransaction, selectedTransferMoneyNode); // If a value was specified for the conversion to other currency, // use that value instead of the negation of current one if (currencyConversionValue != null) { otherTransaction.setValue(currencyConversionValue); } newTransaction.setTransferTransaction(otherTransaction); otherTransaction.setTransferTransaction(newTransaction); } listener.onImmediateTransactionCreated(newTransaction); } // If we are updating an existing transaction else { ImmedTransactionEditOldInfo oldInfo = new ImmedTransactionEditOldInfo(transaction); transaction.setDescription(description); transaction.setCategory(selectedCategory); transaction.setExecutionDate(executionDateTime); transaction.setValue(value); if (isTransfer && selectedTransferMoneyNode != null) { ImmediateTransaction otherTransaction = null; // If edited transaction wasn't part of a transfer and // now is, create transfer transaction if (transaction.getTransferTransaction() == null) { otherTransaction = new ImmediateTransaction(transaction, selectedTransferMoneyNode); transaction.setTransferTransaction(otherTransaction); otherTransaction.setTransferTransaction(transaction); } // If edited transaction was already part of a // transfer, update transfer transaction else { otherTransaction = transaction.getTransferTransaction(); otherTransaction.setMoneyNode(selectedTransferMoneyNode); otherTransaction.setDescription(description); otherTransaction.setCategory(selectedCategory); otherTransaction.setExecutionDate(executionDateTime); otherTransaction.setValue(value.negated()); } // If a value was specified for the conversion to other currency, // use that value instead of the negation of current one if (currencyConversionValue != null) { otherTransaction.setValue(currencyConversionValue); } } // If edited transaction no longer is a transfer but // was a transfer before, we need to remove the opposite // transaction. else if (transaction.getTransferTransaction() != null) { transaction.setTransferTransaction(null); } listener.onImmediateTransactionEdited(transaction, oldInfo); } } }); this.savedInstanceState = savedInstanceState; return v; }
From source file:org.hawkular.client.android.fragment.ConfirmOperationFragment.java
private void createTable(OperationProperties operationProperties) { TableRow row = null;/* www . j av a2 s. c o m*/ Map<String, OperationParameter> operationParameters = operationProperties.getOperationParameters(); if (operationParameters != null) { for (Map.Entry<String, OperationParameter> entry : operationParameters.entrySet()) { switch (entry.getValue().getType()) { case "string": { row = (TableRow) LayoutInflater.from(getActivity()).inflate(R.layout.row_edit, null); EditText data = (EditText) row.findViewById(R.id.data); data.setText(entry.getValue().getDefaultValue()); data.setInputType(InputType.TYPE_CLASS_TEXT); break; } case "int": { row = (TableRow) LayoutInflater.from(getActivity()).inflate(R.layout.row_edit, null); EditText data = (EditText) row.findViewById(R.id.data); data.setText(entry.getValue().getDefaultValue()); data.setInputType(InputType.TYPE_CLASS_NUMBER); break; } case "float": { row = (TableRow) LayoutInflater.from(getActivity()).inflate(R.layout.row_edit, null); EditText data = (EditText) row.findViewById(R.id.data); data.setText(entry.getValue().getDefaultValue()); data.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL); break; } case "bool": { row = (TableRow) LayoutInflater.from(getActivity()).inflate(R.layout.row_toggle, null); SwitchCompat data = (SwitchCompat) row.findViewById(R.id.data); data.setChecked(entry.getValue().getDefaultValue().equals("true")); break; } } if (row != null) { TextView name = (TextView) row.findViewById(R.id.name); name.setText(entry.getKey()); table.addView(row); } } table.requestLayout(); } }
From source file:com.app_software.chromisstock.StockChangeDialog.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); // Get the layout inflater LayoutInflater inflater = getActivity().getLayoutInflater(); // Inflate and set the layout for the dialog // Pass null as the parent view because its going in the dialog layout View v = inflater.inflate(R.layout.dialog_stock_change, null); // Set information given in the Intent m_txtProductName = (TextView) v.findViewById(R.id.txtProductName); m_txtField = (TextView) v.findViewById(R.id.txtField); m_editNewValue = (EditText) v.findViewById(R.id.editNewValue); m_rbIncrease = (RadioButton) v.findViewById(R.id.rbIncrease); m_rbDecrease = (RadioButton) v.findViewById(R.id.rbDecrease); m_rbSetValue = (RadioButton) v.findViewById(R.id.rbSetValue); m_rbIncrease.setEnabled(m_bAllowAdjust); m_rbDecrease.setEnabled(m_bAllowAdjust); DatabaseHandler db = DatabaseHandler.getInstance(getActivity()); StockProduct product = db.getProduct(m_ProductID, true); if (product == null) { Log.e(TAG, "Product not found"); m_txtProductName.setText("DATABASE ERROR!!"); } else {/*from w w w . ja v a 2s .c o m*/ m_ChromisID = product.getChromisId(); String name; if (TextUtils.isEmpty(product.getValueString(StockProduct.NAME))) { name = getResources().getString(R.string.change_newproduct); } else { name = product.getValueString(StockProduct.NAME); } m_txtProductName.setText(name); m_txtField.setText(m_FieldLabel); if (m_ChangeType == DatabaseHandler.CHANGETYPE_ADJUSTVALUE) { Double d = new Double(m_Value); if (d < 0) { m_rbDecrease.setChecked(true); d = d * -1; m_Value = String.format("%.0f", d); } else { m_rbIncrease.setChecked(true); } } else { m_rbSetValue.setChecked(true); } if (m_bIsNumber) { m_editNewValue.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL); } else { m_editNewValue.setInputType(InputType.TYPE_CLASS_TEXT); m_editNewValue.setText(m_Value); } m_editNewValue.setHint(m_Value); } // Add action buttons builder.setView(v).setPositiveButton(R.string.label_ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { // Create a new change record createChangeRecord(); } }).setNegativeButton(R.string.label_cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { } }); return builder.create(); }
From source file:eu.hydrologis.geopaparazzi.maptools.FeaturePageAdapter.java
@Override public Object instantiateItem(ViewGroup container, int position) { final Feature feature = featuresList.get(position); int bgColor = context.getResources().getColor(R.color.formbgcolor); int textColor = context.getResources().getColor(R.color.formcolor); ScrollView scrollView = new ScrollView(context); ScrollView.LayoutParams scrollLayoutParams = new ScrollView.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);//from w w w.java 2 s .c om scrollLayoutParams.setMargins(10, 10, 10, 10); scrollView.setLayoutParams(scrollLayoutParams); scrollView.setBackgroundColor(bgColor); LinearLayout linearLayoutView = new LinearLayout(context); LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); int margin = 10; layoutParams.setMargins(margin, margin, margin, margin); linearLayoutView.setLayoutParams(layoutParams); linearLayoutView.setOrientation(LinearLayout.VERTICAL); int padding = 10; linearLayoutView.setPadding(padding, padding, padding, padding); scrollView.addView(linearLayoutView); List<String> attributeNames = feature.getAttributeNames(); List<String> attributeValues = feature.getAttributeValuesStrings(); List<String> attributeTypes = feature.getAttributeTypes(); for (int i = 0; i < attributeNames.size(); i++) { final String name = attributeNames.get(i); String value = attributeValues.get(i); String typeString = attributeTypes.get(i); DataType type = DataType.getType4Name(typeString); TextView textView = new TextView(context); textView.setLayoutParams( new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); textView.setPadding(padding, padding, padding, padding); textView.setText(name); textView.setTextColor(textColor); // textView.setTextAppearance(context, android.R.style.TextAppearance_Medium); linearLayoutView.addView(textView); final EditText editView = new EditText(context); LinearLayout.LayoutParams editViewParams = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); editViewParams.setMargins(margin, 0, margin, 0); editView.setLayoutParams(editViewParams); editView.setPadding(padding * 2, padding, padding * 2, padding); editView.setText(value); // editView.setEnabled(!isReadOnly); editView.setFocusable(!isReadOnly); // editView.setTextAppearance(context, android.R.style.TextAppearance_Medium); if (isReadOnly) { editView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { String text = editView.getText().toString(); FeatureUtilities.viewIfApplicable(v.getContext(), text); return false; } }); } switch (type) { case DOUBLE: case FLOAT: editView.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL); break; case PHONE: editView.setInputType(InputType.TYPE_CLASS_PHONE); break; case DATE: editView.setInputType(InputType.TYPE_CLASS_DATETIME); break; case INTEGER: editView.setInputType(InputType.TYPE_CLASS_NUMBER); break; default: break; } editView.addTextChangedListener(new TextWatcher() { public void onTextChanged(CharSequence s, int start, int before, int count) { // ignore } public void beforeTextChanged(CharSequence s, int start, int count, int after) { // ignore } public void afterTextChanged(Editable s) { String text = editView.getText().toString(); feature.setAttribute(name, text); } }); linearLayoutView.addView(editView); } /* * add also area and length */ if (feature.getOriginalArea() > -1) { TextView areaTextView = new TextView(context); areaTextView.setLayoutParams( new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); areaTextView.setPadding(padding, padding, padding, padding); areaTextView.setText("Area: " + areaLengthFormatter.format(feature.getOriginalArea())); areaTextView.setTextColor(textColor); TextView lengthTextView = new TextView(context); lengthTextView.setLayoutParams( new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); lengthTextView.setPadding(padding, padding, padding, padding); lengthTextView.setText("Length: " + areaLengthFormatter.format(feature.getOriginalLength())); lengthTextView.setTextColor(textColor); linearLayoutView.addView(areaTextView); linearLayoutView.addView(lengthTextView); } container.addView(scrollView); return scrollView; }