List of usage examples for android.widget EditText EditText
public EditText(Context context)
From source file:bizapps.com.healthforusPatient.activity.RegisterActivity.java
public void verifyAccount() { final AlertDialog builder = new AlertDialog.Builder(this, R.style.InvitationDialog) .setPositiveButton("Done", null).setNegativeButton("Cancel", null).create(); LinearLayout layout = new LinearLayout(this); layout.setOrientation(LinearLayout.VERTICAL); final EditText emailBox = new EditText(this); emailBox.setTextColor(getResources().getColor(R.color.icons)); emailBox.setHintTextColor(getResources().getColor(R.color.icons)); emailBox.setHint("Email"); layout.addView(emailBox);//from w w w .j a v a2 s .c o m final EditText codeBox = new EditText(this); codeBox.setTextColor(getResources().getColor(R.color.icons)); codeBox.setHintTextColor(getResources().getColor(R.color.icons)); codeBox.setHint("Code"); layout.addView(codeBox); builder.setView(layout); // final EditText etNickName = new EditText(this); // etNickName.setTextColor(Color.parseColor("#FFFFFF")); // builder.setView(etNickName); builder.setTitle("Verify registration"); builder.setMessage("Enter emailId and code to activate account"); builder.setOnShowListener(new DialogInterface.OnShowListener() { @Override public void onShow(DialogInterface dialog) { final Button btnAccept = builder.getButton(AlertDialog.BUTTON_POSITIVE); btnAccept.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (emailBox.getText().toString().isEmpty() && codeBox.getText().toString().isEmpty()) { Toast.makeText(getApplicationContext(), "Fields cannot be empty", Toast.LENGTH_SHORT) .show(); } else { verifyApi(emailBox.getText().toString(), codeBox.getText().toString()); builder.dismiss(); } } }); final Button btnDecline = builder.getButton(DialogInterface.BUTTON_NEGATIVE); btnDecline.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { builder.dismiss(); } }); } }); builder.show(); }
From source file:de.ub0r.android.callmeter.ui.prefs.Preferences.java
/** * Export data./*from w w w .j ava 2 s.com*/ * * @param descr * description of the exported rule set * @param fn * one of the predefined file names from {@link DataProvider}. */ private void exportData(final String descr, final String fn) { if (descr == null) { final EditText et = new EditText(this); Builder builder = new Builder(this); builder.setView(et); builder.setCancelable(true); builder.setTitle(R.string.export_rules_descr); builder.setNegativeButton(android.R.string.cancel, null); builder.setPositiveButton(android.R.string.ok, new OnClickListener() { @Override public void onClick(final DialogInterface dialog, final int which) { Preferences.this.exportData(et.getText().toString(), fn); } }); builder.show(); } else { final ProgressDialog d = new ProgressDialog(this); d.setIndeterminate(true); d.setMessage(this.getString(R.string.export_progr)); d.setCancelable(false); d.show(); // run task in background final AsyncTask<Void, Void, String> task = // . new AsyncTask<Void, Void, String>() { @Override protected String doInBackground(final Void... params) { if (fn.equals(DataProvider.EXPORT_RULESET_FILE)) { return DataProvider.backupRuleSet(Preferences.this, descr); } else if (fn.equals(DataProvider.EXPORT_LOGS_FILE)) { return DataProvider.backupLogs(Preferences.this, descr); } else if (fn.equals(DataProvider.EXPORT_NUMGROUPS_FILE)) { return DataProvider.backupNumGroups(Preferences.this, descr); } else if (fn.equals(DataProvider.EXPORT_HOURGROUPS_FILE)) { return DataProvider.backupHourGroups(Preferences.this, descr); } return null; } @Override protected void onPostExecute(final String result) { Log.d(TAG, "export:\n" + result); System.out.println("\n" + result); d.dismiss(); if (result != null && result.length() > 0) { Uri uri = null; int resChooser = -1; if (fn.equals(DataProvider.EXPORT_RULESET_FILE)) { uri = DataProvider.EXPORT_RULESET_URI; resChooser = R.string.export_rules_; } else if (fn.equals(DataProvider.EXPORT_LOGS_FILE)) { uri = DataProvider.EXPORT_LOGS_URI; resChooser = R.string.export_logs_; } else if (fn.equals(DataProvider.EXPORT_NUMGROUPS_FILE)) { uri = DataProvider.EXPORT_NUMGROUPS_URI; resChooser = R.string.export_numgroups_; } else if (fn.equals(DataProvider.EXPORT_HOURGROUPS_FILE)) { uri = DataProvider.EXPORT_HOURGROUPS_URI; resChooser = R.string.export_hourgroups_; } final Intent intent = new Intent(Intent.ACTION_SEND); intent.setType(DataProvider.EXPORT_MIMETYPE); intent.putExtra(Intent.EXTRA_STREAM, uri); intent.putExtra(Intent.EXTRA_SUBJECT, // . "Call Meter 3G export"); intent.addCategory(Intent.CATEGORY_DEFAULT); try { final File d = Environment.getExternalStorageDirectory(); final File f = new File(d, DataProvider.PACKAGE + File.separator + fn); f.mkdirs(); if (f.exists()) { f.delete(); } f.createNewFile(); FileWriter fw = new FileWriter(f); fw.append(result); fw.close(); // call an exporting app with the uri to the // preferences Preferences.this.startActivity( Intent.createChooser(intent, Preferences.this.getString(resChooser))); } catch (IOException e) { Log.e(TAG, "error writing export file", e); Toast.makeText(Preferences.this, R.string.err_export_write, Toast.LENGTH_LONG) .show(); } } } }; task.execute((Void) null); } }
From source file:de.hshannover.f4.trust.ironcontrol.view.AdvancedRequestFragment.java
public Dialog createSubscribeSaveDialog() { AlertDialog.Builder publishSaveDialog = new AlertDialog.Builder(getActivity()); publishSaveDialog.setTitle(R.string.save); publishSaveDialog.setMessage(R.string.saving_subscribe_message); final EditText input = new EditText(getActivity()); input.setText(etName.getText().toString()); publishSaveDialog.setView(input);//w w w .j a v a 2s . c o m publishSaveDialog.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int whichButton) { if (saveSubscribtion(input.getText().toString()) == null) { Toast.makeText(getActivity(), "not saved", Toast.LENGTH_LONG).show(); } else { Toast.makeText(getActivity(), "Subscription: " + input.getText().toString() + " is saved", Toast.LENGTH_SHORT).show(); } } }); publishSaveDialog.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int whichButton) { } }); return publishSaveDialog.create(); }
From source file:com.geotrackin.gpslogger.GpsMainActivity.java
/** * Annotates GPX and KML files, TXT files are ignored. * <p/>//from w w w . j a v a 2s .c o m * The annotation is done like this: * <wpt lat="##.##" lon="##.##"> * <name>user input</name> * </wpt> * <p/> * The user is prompted for the content of the <name> tag. If a valid * description is given, the logging service starts in single point mode. */ private void Annotate() { if (!AppSettings.shouldLogToGpx() && !AppSettings.shouldLogToKml() && !AppSettings.shouldLogToCustomUrl()) { tracer.debug("GPX, KML, URL disabled; annotation shouldn't work"); Toast.makeText(getApplicationContext(), getString(R.string.annotation_requires_logging), Toast.LENGTH_SHORT).show(); return; } AlertDialog.Builder alert = new AlertDialog.Builder(GpsMainActivity.this); alert.setTitle(R.string.add_description); alert.setMessage(R.string.letters_numbers); // Set an EditText view to get user input final EditText input = new EditText(getApplicationContext()); input.setTextColor(getResources().getColor(android.R.color.black)); input.setBackgroundColor(getResources().getColor(android.R.color.white)); input.setText(Session.getDescription()); alert.setView(input); /* ok */ alert.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { final String desc = Utilities.CleanDescription(input.getText().toString()); if (desc.length() == 0) { tracer.debug("Clearing annotation"); Session.clearDescription(); OnClearAnnotation(); } else { tracer.debug("Setting annotation: " + desc); Session.setDescription(desc); OnSetAnnotation(); // logOnce will start single point mode. if (!Session.isStarted()) { tracer.debug("Will start log-single-point"); LogSinglePoint(); } } } }); alert.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { // Cancelled. } }); AlertDialog alertDialog = alert.create(); alertDialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE); alertDialog.show(); }
From source file:br.com.carlosrafaelgn.fplay.ActivityBrowserRadio.java
@Override public void onClick(View view) { if (view == btnGoBack) { if (isAtFavorites) { isAtFavorites = false;//www .j a v a 2 s . com doSearch(); } else { finish(0, view, true); } } else if (view == btnFavorite) { isAtFavorites = true; radioStationList.cancel(); radioStationList.fetchFavorites(getApplication()); updateButtons(); } else if (view == btnSearch) { final Context ctx = getHostActivity(); final LinearLayout l = (LinearLayout) UI.createDialogView(ctx, null); LinearLayout.LayoutParams p = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); chkGenre = new RadioButton(ctx); chkGenre.setText(R.string.genre); chkGenre.setChecked(Player.lastRadioSearchWasByGenre); chkGenre.setOnClickListener(this); chkGenre.setTextSize(TypedValue.COMPLEX_UNIT_PX, UI._DLGsp); chkGenre.setLayoutParams(p); p = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); p.topMargin = UI._DLGsppad; btnGenre = new Spinner(ctx); btnGenre.setContentDescription(ctx.getText(R.string.genre)); btnGenre.setLayoutParams(p); p = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); p.topMargin = UI._DLGsppad << 1; chkTerm = new RadioButton(ctx); chkTerm.setText(R.string.search_term); chkTerm.setChecked(!Player.lastRadioSearchWasByGenre); chkTerm.setOnClickListener(this); chkTerm.setTextSize(TypedValue.COMPLEX_UNIT_PX, UI._DLGsp); chkTerm.setLayoutParams(p); p = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); p.topMargin = UI._DLGsppad; txtTerm = new EditText(ctx); txtTerm.setContentDescription(ctx.getText(R.string.search_term)); txtTerm.setText(Player.radioSearchTerm == null ? "" : Player.radioSearchTerm); txtTerm.setOnClickListener(this); txtTerm.setTextSize(TypedValue.COMPLEX_UNIT_PX, UI._DLGsp); txtTerm.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_SENTENCES); txtTerm.setSingleLine(); txtTerm.setLayoutParams(p); p = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); p.topMargin = UI._DLGsppad; p.bottomMargin = UI._DLGsppad; final TextView lbl = new TextView(ctx); lbl.setAutoLinkMask(0); lbl.setLinksClickable(true); //http://developer.android.com/design/style/color.html lbl.setLinkTextColor(new BgColorStateList(UI.isAndroidThemeLight() ? 0xff0099cc : 0xff33b5e5)); lbl.setTextSize(TypedValue.COMPLEX_UNIT_PX, UI._14sp); lbl.setGravity(Gravity.CENTER_HORIZONTAL); lbl.setText(SafeURLSpan.parseSafeHtml(getText(R.string.by_dir_xiph_org))); lbl.setMovementMethod(LinkMovementMethod.getInstance()); lbl.setLayoutParams(p); l.addView(chkGenre); l.addView(btnGenre); l.addView(chkTerm); l.addView(txtTerm); l.addView(lbl); btnGenre.setAdapter(this); btnGenre.setSelection(getValidGenre(Player.radioLastGenre)); defaultTextColors = txtTerm.getTextColors(); UI.prepareDialogAndShow((new AlertDialog.Builder(ctx)).setTitle(getText(R.string.search)).setView(l) .setPositiveButton(R.string.search, this).setNegativeButton(R.string.cancel, this) .setOnCancelListener(this).create()); } else if (view == btnGoBackToPlayer) { finish(-1, view, false); } else if (view == btnAdd) { addPlaySelectedItem(false); } else if (view == btnPlay) { addPlaySelectedItem(true); } else if (view == chkGenre || view == btnGenre) { chkGenre.setChecked(true); chkTerm.setChecked(false); } else if (view == chkTerm || view == txtTerm) { chkGenre.setChecked(false); chkTerm.setChecked(true); } else if (view == list) { if (!isAtFavorites && !loading && (radioStationList == null || radioStationList.getCount() == 0)) onClick(btnFavorite); } }
From source file:com.citrus.sample.WalletPaymentFragment.java
private void showCashoutPrompt() { final AlertDialog.Builder alert = new AlertDialog.Builder(getActivity()); String message = "Please enter account details."; String positiveButtonText = "Withdraw"; LinearLayout linearLayout = new LinearLayout(getActivity()); linearLayout.setOrientation(LinearLayout.VERTICAL); final TextView labelAmount = new TextView(getActivity()); final EditText editAmount = new EditText(getActivity()); final TextView labelAccountNo = new TextView(getActivity()); final EditText editAccountNo = new EditText(getActivity()); editAccountNo.setSingleLine(true);/* w w w . ja va 2s.com*/ final TextView labelAccountHolderName = new TextView(getActivity()); final EditText editAccountHolderName = new EditText(getActivity()); editAccountHolderName.setSingleLine(true); final TextView labelIfscCode = new TextView(getActivity()); final EditText editIfscCode = new EditText(getActivity()); editIfscCode.setSingleLine(true); labelAmount.setText("Withdrawal Amount"); labelAccountNo.setText("Account Number"); labelAccountHolderName.setText("Account Holder Name"); labelIfscCode.setText("IFSC Code"); LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); labelAmount.setLayoutParams(layoutParams); labelAccountNo.setLayoutParams(layoutParams); labelAccountHolderName.setLayoutParams(layoutParams); labelIfscCode.setLayoutParams(layoutParams); editAmount.setLayoutParams(layoutParams); editAccountNo.setLayoutParams(layoutParams); editAccountHolderName.setLayoutParams(layoutParams); editIfscCode.setLayoutParams(layoutParams); linearLayout.addView(labelAmount); linearLayout.addView(editAmount); linearLayout.addView(labelAccountNo); linearLayout.addView(editAccountNo); linearLayout.addView(labelAccountHolderName); linearLayout.addView(editAccountHolderName); linearLayout.addView(labelIfscCode); linearLayout.addView(editIfscCode); int paddingPx = Utils.getSizeInPx(getActivity(), 32); linearLayout.setPadding(paddingPx, paddingPx, paddingPx, paddingPx); editAmount.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL); alert.setTitle("Withdraw Money To Your Account"); alert.setMessage(message); alert.setView(linearLayout); alert.setPositiveButton(positiveButtonText, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { String amount = editAmount.getText().toString(); String accontNo = editAccountNo.getText().toString(); String accountHolderName = editAccountHolderName.getText().toString(); String ifsc = editIfscCode.getText().toString(); CashoutInfo cashoutInfo = new CashoutInfo(new Amount(amount), accontNo, accountHolderName, ifsc); mListener.onCashoutSelected(cashoutInfo); // Hide the keyboard. InputMethodManager imm = (InputMethodManager) getActivity() .getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(editAmount.getWindowToken(), 0); } }); alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.cancel(); } }); editAmount.requestFocus(); alert.show(); }
From source file:com.sigilance.CardEdit.MainActivity.java
private void promptForTextDo(final int slot) { AlertDialog.Builder builder = new AlertDialog.Builder(this); final EditText input = new EditText(this); final EditText input2 = new EditText(this); input.setInputType(InputType.TYPE_CLASS_TEXT); input2.setInputType(InputType.TYPE_CLASS_TEXT); LinearLayout fields = new LinearLayout(this); fields.setOrientation(LinearLayout.VERTICAL); fields.addView(input);//from w w w . j av a2 s . co m switch (slot) { case DO_NAME: builder.setTitle(R.string.lbl_cardholder_name); input.setHint(R.string.hint_surname); input2.setHint(R.string.hint_given_name); input.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_WORDS); input2.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_WORDS); String[] names = mCardholderName.split("<<"); if (names.length > 1) { input.setText(names[0].replace('<', ' ')); input2.setText(names[1].replace('<', ' ')); } fields.addView(input2); break; case DO_LANGUAGE: builder.setTitle(R.string.lbl_language_prefs); builder.setMessage("Use a two-letter ISO 639-1 language code: en for English, es for Spanish, etc."); input.setFilters(new InputFilter[] { new InputFilter.LengthFilter(2) }); input.setText(mCardholderLanguage); break; case DO_LOGIN_DATA: builder.setTitle(R.string.lbl_login_data); builder.setMessage( "This is arbitrary text; you can use this field to store a username, email address or network logon."); input.setFilters(new InputFilter[] { new InputFilter.LengthFilter(254) }); input.setText(new String(mLoginData)); break; case DO_URL: builder.setTitle(R.string.lbl_url); input.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_URI); input.setFilters(new InputFilter[] { new InputFilter.LengthFilter(254) }); input.setText(mUrl); break; } builder.setView(fields); builder.setPositiveButton("OK", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { byte[] data; String text = input.getText().toString(); switch (slot) { case DO_NAME: String surname = text.trim().replace(' ', '<'); String givenNames = input2.getText().toString().trim().replace(' ', '<'); data = (surname + "<<" + givenNames).getBytes(Charset.forName("ISO-8859-1")); if (data.length > 39) { Toast.makeText(MainActivity.this, "Name is too long!", Toast.LENGTH_LONG).show(); return; } break; case DO_LANGUAGE: if (text.length() == 2) data = text.toLowerCase().getBytes(); else data = new byte[0]; break; case DO_URL: case DO_LOGIN_DATA: data = text.getBytes(); break; default: data = new byte[0]; } mPendingOperations.add(new PendingPutDataOperation(slot, data)); hideUi(); findTextViewById(R.id.id_action_reqiured_warning).setText(R.string.warning_tap_card_to_save); } }); builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); builder.create().show(); }
From source file:com.mifos.mifosxdroid.online.generatecollectionsheet.GenerateCollectionSheetFragment.java
private void inflateCollectionTable(CollectionSheetResponse collectionSheetResponse) { //Clear old views in case they are present. if (tableProductive.getChildCount() > 0) { tableProductive.removeAllViews(); }// w ww. j ava 2 s . c o m //A List to be used to inflate Attendance Spinners ArrayList<String> attendanceTypes = new ArrayList<>(); attendanceTypeOptions.clear(); attendanceTypeOptions = presenter.filterAttendanceTypes(collectionSheetResponse.getAttendanceTypeOptions(), attendanceTypes); additionalPaymentTypeMap.clear(); additionalPaymentTypeMap = presenter.filterPaymentTypes(collectionSheetResponse.getPaymentTypeOptions(), paymentTypes); //Add the heading Row TableRow headingRow = new TableRow(getContext()); TableRow.LayoutParams headingRowParams = new TableRow.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); headingRowParams.gravity = Gravity.CENTER; headingRowParams.setMargins(0, 0, 0, 10); headingRow.setLayoutParams(headingRowParams); TextView tvGroupName = new TextView(getContext()); tvGroupName.setText(collectionSheetResponse.getGroups().get(0).getGroupName()); tvGroupName.setTypeface(tvGroupName.getTypeface(), Typeface.BOLD); tvGroupName.setGravity(Gravity.CENTER); headingRow.addView(tvGroupName); for (LoanProducts loanProduct : collectionSheetResponse.getLoanProducts()) { TextView tvProduct = new TextView(getContext()); tvProduct.setText(getString(R.string.collection_loan_product, loanProduct.getName())); tvProduct.setTypeface(tvProduct.getTypeface(), Typeface.BOLD); tvProduct.setGravity(Gravity.CENTER); headingRow.addView(tvProduct); } for (SavingsProduct savingsProduct : collectionSheetResponse.getSavingsProducts()) { TextView tvSavingProduct = new TextView(getContext()); tvSavingProduct.setText(getString(R.string.collection_saving_product, savingsProduct.getName())); tvSavingProduct.setTypeface(tvSavingProduct.getTypeface(), Typeface.BOLD); tvSavingProduct.setGravity(Gravity.CENTER); headingRow.addView(tvSavingProduct); } TextView tvAttendance = new TextView(getContext()); tvAttendance.setText(getString(R.string.attendance)); tvAttendance.setGravity(Gravity.CENTER); tvAttendance.setTypeface(tvAttendance.getTypeface(), Typeface.BOLD); headingRow.addView(tvAttendance); tableProductive.addView(headingRow); for (ClientCollectionSheet clientCollectionSheet : collectionSheetResponse.getGroups().get(0) .getClients()) { //Insert rows TableRow row = new TableRow(getContext()); TableRow.LayoutParams rowParams = new TableRow.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); rowParams.gravity = Gravity.CENTER; rowParams.setMargins(0, 0, 0, 10); row.setLayoutParams(rowParams); //Column 1: Client Name and Id TextView tvClientName = new TextView(getContext()); tvClientName.setText( concatIdWithName(clientCollectionSheet.getClientName(), clientCollectionSheet.getClientId())); row.addView(tvClientName); //Subsequent columns: The Loan products for (LoanProducts loanProduct : collectionSheetResponse.getLoanProducts()) { //Since there may be several items in this column, create a container. LinearLayout productContainer = new LinearLayout(getContext()); productContainer.setOrientation(LinearLayout.HORIZONTAL); //Iterate through all the loans in of this type and add in the container for (LoanCollectionSheet loan : clientCollectionSheet.getLoans()) { if (loanProduct.getName().equals(loan.getProductShortName())) { //This loan should be shown in this column. So, add it in the container. EditText editText = new EditText(getContext()); editText.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL); editText.setText(String.format(Locale.getDefault(), "%f", 0.0)); //Set the loan id as the Tag of the EditText // in format 'TYPE:ID' which //will later be used as the identifier for this. editText.setTag(TYPE_LOAN + ":" + loan.getLoanId()); productContainer.addView(editText); } } row.addView(productContainer); } //After Loans, show Savings columns for (SavingsProduct product : collectionSheetResponse.getSavingsProducts()) { //Since there may be several Savings items in this column, create a container. LinearLayout productContainer = new LinearLayout(getContext()); productContainer.setOrientation(LinearLayout.HORIZONTAL); //Iterate through all the Savings in of this type and add in the container for (SavingsCollectionSheet saving : clientCollectionSheet.getSavings()) { if (saving.getProductId() == product.getId()) { //Add the saving in the container EditText editText = new EditText(getContext()); editText.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL); editText.setText(String.format(Locale.getDefault(), "%f", 0.0)); //Set the Saving id as the Tag of the EditText // in 'TYPE:ID' format which //will later be used as the identifier for this. editText.setTag(TYPE_SAVING + ":" + saving.getSavingsId()); productContainer.addView(editText); } } row.addView(productContainer); } Spinner spAttendance = new Spinner(getContext()); //Set the clientId as its tag which will be used as identifier later. spAttendance.setTag(clientCollectionSheet.getClientId()); setSpinner(spAttendance, attendanceTypes); row.addView(spAttendance); tableProductive.addView(row); } if (btnSubmitProductive.getVisibility() != View.VISIBLE) { //Show the button the first time sheet is loaded. btnSubmitProductive.setVisibility(View.VISIBLE); btnSubmitProductive.setOnClickListener(this); } //If this block has been executed, that means the CollectionSheet //which is already shown is for groups. btnSubmitProductive.setTag(TAG_TYPE_COLLECTION); if (tableAdditional.getVisibility() != View.VISIBLE) { tableAdditional.setVisibility(View.VISIBLE); } //Show Additional Views TableRow rowPayment = new TableRow(getContext()); TextView tvLabelPayment = new TextView(getContext()); tvLabelPayment.setText(getString(R.string.payment_type)); rowPayment.addView(tvLabelPayment); Spinner spPayment = new Spinner(getContext()); setSpinner(spPayment, paymentTypes); rowPayment.addView(spPayment); tableAdditional.addView(rowPayment); TableRow rowAccount = new TableRow(getContext()); TextView tvLabelAccount = new TextView(getContext()); tvLabelAccount.setText(getString(R.string.account_number)); rowAccount.addView(tvLabelAccount); EditText etPayment = new EditText(getContext()); rowAccount.addView(etPayment); tableAdditional.addView(rowAccount); TableRow rowCheck = new TableRow(getContext()); TextView tvLabelCheck = new TextView(getContext()); tvLabelCheck.setText(getString(R.string.cheque_number)); rowCheck.addView(tvLabelCheck); EditText etCheck = new EditText(getContext()); rowCheck.addView(etCheck); tableAdditional.addView(rowCheck); TableRow rowRouting = new TableRow(getContext()); TextView tvLabelRouting = new TextView(getContext()); tvLabelRouting.setText(getString(R.string.routing_code)); rowRouting.addView(tvLabelRouting); EditText etRouting = new EditText(getContext()); rowRouting.addView(etRouting); tableAdditional.addView(rowRouting); TableRow rowReceipt = new TableRow(getContext()); TextView tvLabelReceipt = new TextView(getContext()); tvLabelReceipt.setText(getString(R.string.receipt_number)); rowReceipt.addView(tvLabelReceipt); EditText etReceipt = new EditText(getContext()); rowReceipt.addView(etReceipt); tableAdditional.addView(rowReceipt); TableRow rowBank = new TableRow(getContext()); TextView tvLabelBank = new TextView(getContext()); tvLabelBank.setText(getString(R.string.bank_number)); rowBank.addView(tvLabelBank); EditText etBank = new EditText(getContext()); rowBank.addView(etBank); tableAdditional.addView(rowBank); }
From source file:com.microsoft.windowsazure.mobileservices.authentication.LoginManager.java
/** * Creates the UI for the interactive authentication process * * @param startUrl The initial URL for the authentication process * @param endUrl The final URL for the authentication process * @param context The context used to create the authentication dialog * @param callback Callback to invoke when the authentication process finishes *//*from w ww. j a v a 2 s .c o m*/ private void showLoginUIInternal(final String startUrl, final String endUrl, final Context context, LoginUIOperationCallback callback) { if (startUrl == null || startUrl == "") { throw new IllegalArgumentException("startUrl can not be null or empty"); } if (endUrl == null || endUrl == "") { throw new IllegalArgumentException("endUrl can not be null or empty"); } if (context == null) { throw new IllegalArgumentException("context can not be null"); } final LoginUIOperationCallback externalCallback = callback; final AlertDialog.Builder builder = new AlertDialog.Builder(context); // Create the Web View to show the login page final WebView wv = new WebView(context); builder.setOnCancelListener(new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { if (externalCallback != null) { externalCallback.onCompleted(null, new MobileServiceException("User Canceled")); } } }); wv.getSettings().setJavaScriptEnabled(true); DisplayMetrics displaymetrics = new DisplayMetrics(); ((Activity) context).getWindowManager().getDefaultDisplay().getMetrics(displaymetrics); int webViewHeight = displaymetrics.heightPixels - 100; wv.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, webViewHeight)); wv.requestFocus(View.FOCUS_DOWN); wv.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View view, MotionEvent event) { int action = event.getAction(); if (action == MotionEvent.ACTION_DOWN || action == MotionEvent.ACTION_UP) { if (!view.hasFocus()) { view.requestFocus(); } } return false; } }); // Create a LinearLayout and add the WebView to the Layout LinearLayout layout = new LinearLayout(context); layout.setOrientation(LinearLayout.VERTICAL); layout.addView(wv); // Add a dummy EditText to the layout as a workaround for a bug // that prevents showing the keyboard for the WebView on some devices EditText dummyEditText = new EditText(context); dummyEditText.setVisibility(View.GONE); layout.addView(dummyEditText); // Add the layout to the dialog builder.setView(layout); final AlertDialog dialog = builder.create(); wv.setWebViewClient(new WebViewClient() { @Override public void onPageStarted(WebView view, String url, Bitmap favicon) { // If the URL of the started page matches with the final URL // format, the login process finished if (isFinalUrl(url)) { if (externalCallback != null) { externalCallback.onCompleted(url, null); } dialog.dismiss(); } super.onPageStarted(view, url, favicon); } // Checks if the given URL matches with the final URL's format private boolean isFinalUrl(String url) { if (url == null) { return false; } return url.startsWith(endUrl); } // Checks if the given URL matches with the start URL's format private boolean isStartUrl(String url) { if (url == null) { return false; } return url.startsWith(startUrl); } @Override public void onPageFinished(WebView view, String url) { if (isStartUrl(url)) { if (externalCallback != null) { externalCallback.onCompleted(null, new MobileServiceException( "Logging in with the selected authentication provider is not enabled")); } dialog.dismiss(); } } }); wv.loadUrl(startUrl); dialog.show(); }
From source file:info.semanticsoftware.semassist.android.activity.SemanticAssistantsActivity.java
/** Presents additional information about a specific assistant. * @return a dynamically generated linear layout *///from w w w.j a v a 2 s . c o m private LinearLayout getServiceDescLayout() { final LinearLayout output = new LinearLayout(this); final RelativeLayout topButtonsLayout = new RelativeLayout(this); RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); final Button btnBack = new Button(this); btnBack.setText(R.string.btnAllServices); btnBack.setId(5); btnBack.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { output.setVisibility(View.GONE); getListView().setVisibility(View.VISIBLE); lblAvAssist.setVisibility(View.VISIBLE); } }); topButtonsLayout.addView(btnBack); final Button btnInvoke = new Button(this); btnInvoke.setText(R.string.btnInvokeLabel); btnInvoke.setId(6); btnInvoke.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { new InvocationTask().execute(); } }); layoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, btnInvoke.getId()); btnInvoke.setLayoutParams(layoutParams); topButtonsLayout.addView(btnInvoke); output.addView(topButtonsLayout); TableLayout serviceInfoTbl = new TableLayout(this); output.addView(serviceInfoTbl); serviceInfoTbl.setColumnShrinkable(1, true); /* FIRST ROW */ TableRow rowServiceName = new TableRow(this); TextView lblServiceName = new TextView(this); lblServiceName.setText(R.string.lblServiceName); lblServiceName.setTextAppearance(getApplicationContext(), R.style.titleText); TextView txtServiceName = new TextView(this); txtServiceName.setText(selectedService); txtServiceName.setTextAppearance(getApplicationContext(), R.style.normalText); txtServiceName.setPadding(10, 0, 0, 0); rowServiceName.addView(lblServiceName); rowServiceName.addView(txtServiceName); /* SECOND ROW */ TableRow rowServiceDesc = new TableRow(this); TextView lblServiceDesc = new TextView(this); lblServiceDesc.setText(R.string.lblServiceDesc); lblServiceDesc.setTextAppearance(getApplicationContext(), R.style.titleText); TextView txtServiceDesc = new TextView(this); txtServiceDesc.setTextAppearance(getApplicationContext(), R.style.normalText); txtServiceDesc.setPadding(10, 0, 0, 0); List<GateRuntimeParameter> params = null; ServiceInfoForClientArray list = getServices(); for (int i = 0; i < list.getItem().size(); i++) { if (list.getItem().get(i).getServiceName().equals(selectedService)) { txtServiceDesc.setText(list.getItem().get(i).getServiceDescription()); params = list.getItem().get(i).getParams(); break; } } TextView lblParams = new TextView(this); lblParams.setText(R.string.lblServiceParams); lblParams.setTextAppearance(getApplicationContext(), R.style.titleText); output.addView(lblParams); LayoutParams txtParamsAttrbs = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT); LinearLayout paramsLayout = new LinearLayout(this); paramsLayout.setId(0); if (params.size() > 0) { ScrollView scroll = new ScrollView(this); scroll.setLayoutParams(txtParamsAttrbs); paramsLayout.setOrientation(LinearLayout.VERTICAL); scroll.addView(paramsLayout); for (int j = 0; j < params.size(); j++) { TextView lblParamName = new TextView(this); lblParamName.setText(params.get(j).getParamName()); EditText tview = new EditText(this); tview.setId(1); tview.setText(params.get(j).getDefaultValueString()); LayoutParams txtViewLayoutParams = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT); tview.setLayoutParams(txtViewLayoutParams); paramsLayout.addView(lblParamName); paramsLayout.addView(tview); } output.addView(scroll); } else { TextView lblParamName = new TextView(this); lblParamName.setText(R.string.lblRTParams); output.addView(lblParamName); } rowServiceDesc.addView(lblServiceDesc); rowServiceDesc.addView(txtServiceDesc); serviceInfoTbl.addView(rowServiceName); serviceInfoTbl.addView(rowServiceDesc); output.setOrientation(LinearLayout.VERTICAL); output.setGravity(Gravity.TOP); return output; }