List of usage examples for android.widget EditText getText
@Override
public Editable getText()
From source file:com.sixwonders.courtkiosk.CheckInActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); activity = this; view = LayoutInflater.from(this).inflate(R.layout.activity_check_in, null); btnInfoSubmit = (Button) view.findViewById(R.id.btnInfoSubmit); btnIdScan = (Button) view.findViewById(R.id.btnLicenseScan); btnIdScan.setOnClickListener(new View.OnClickListener() { @Override//from w w w . java 2s . c o m public void onClick(View view) { callToScan(); } }); btnInfoSubmit.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { AlertDialog.Builder builder = new AlertDialog.Builder(view.getContext()); builder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { } }); final View custom = LayoutInflater.from(activity) .inflate(R.layout.check_in_personal_info_alertdialog, null); builder.setTitle(R.string.userInformationInput).setPositiveButton(R.string.continueText, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { //TODO call webservice to check for user EditText firstName = (EditText) custom.findViewById(R.id.etFirstName); EditText lastName = (EditText) custom.findViewById(R.id.etLastName); DatePicker dob = (DatePicker) custom.findViewById(R.id.dpDob); if (dob == null) { int i = 0; i++; i++; } int monthInt = dob.getMonth() + 1; String month = ""; if (monthInt < 10) { month += "0"; } month += monthInt; int dayInt = dob.getDayOfMonth(); String day = ""; if (dayInt < 10) { day += "0"; } day += dayInt; int yearInt = dob.getYear(); String year = ""; if (yearInt < 10) { year += "0"; } year += yearInt; String dobStr = month + "/" + day + "/" + year; ConnectionUtil connectionUtil = new ConnectionUtil(); connectionUtil.authCall(firstName.getText().toString(), lastName.getText().toString(), dobStr, (AsyncResponse) activity); } }); builder.setView(custom); datePicker = (DatePicker) custom.findViewById(R.id.dpDob); setUpDatePicker(); AlertDialog alert = builder.create(); alert.show(); } }); setContentView(view); }
From source file:com.dattasmoon.pebble.plugin.EditNotificationActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { if (Constants.IS_LOGGABLE) { Log.i(Constants.LOG_TAG, "Selected menu item id: " + String.valueOf(item.getItemId())); }//from w w w .j a v a 2 s . c om final AlertDialog.Builder builder = new AlertDialog.Builder(this); View v; ListViewHolder viewHolder; AdapterView.AdapterContextMenuInfo contextInfo; String app_name; final String package_name; switch (item.getItemId()) { case R.id.btnUncheckAll: builder.setTitle(R.string.dialog_confirm_title); builder.setMessage(getString(R.string.dialog_uncheck_message)); builder.setCancelable(false); builder.setPositiveButton(R.string.confirm, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int buttonId) { if (lvPackages == null || lvPackages.getAdapter() == null || ((packageAdapter) lvPackages.getAdapter()).selected == null) { //something went wrong return; } ((packageAdapter) lvPackages.getAdapter()).selected.clear(); lvPackages.invalidateViews(); } }); builder.setNegativeButton(R.string.decline, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int buttonId) { //do nothing! } }); builder.setIcon(android.R.drawable.ic_dialog_alert); builder.show(); return true; case R.id.btnSave: finish(); return true; case R.id.btnDonate: Intent i = new Intent(Intent.ACTION_VIEW); i.setData(Uri.parse(Constants.DONATION_URL)); startActivity(i); return true; case R.id.btnSettings: Intent settings = new Intent(this, SettingsActivity.class); startActivity(settings); return true; case R.id.btnRename: contextInfo = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo(); int position = contextInfo.position; long id = contextInfo.id; // the child view who's info we're viewing (should be equal to v) v = contextInfo.targetView; app_name = ((TextView) v.findViewById(R.id.tvPackage)).getText().toString(); viewHolder = (ListViewHolder) v.getTag(); if (viewHolder == null || viewHolder.chkEnabled == null) { //failure return true; } package_name = (String) viewHolder.chkEnabled.getTag(); builder.setTitle(R.string.dialog_title_rename_notification); final EditText input = new EditText(this); input.setHint(app_name); builder.setView(input); builder.setPositiveButton(R.string.confirm, null); builder.setNegativeButton(R.string.decline, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { //do nothing } }); final AlertDialog d = builder.create(); d.setOnShowListener(new DialogInterface.OnShowListener() { @Override public void onShow(DialogInterface dialog) { Button b = d.getButton(AlertDialog.BUTTON_POSITIVE); if (b != null) { b.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { //can't be nothing if (input.getText().length() > 0) { if (Constants.IS_LOGGABLE) { Log.i(Constants.LOG_TAG, "Adding rename for " + package_name + " to " + input.getText()); } JSONObject rename = new JSONObject(); try { rename.put("pkg", package_name); rename.put("to", input.getText()); arrayRenames.put(rename); } catch (JSONException e) { e.printStackTrace(); } ((packageAdapter) lvPackages.getAdapter()).notifyDataSetChanged(); d.dismiss(); } else { input.setText(R.string.error_cant_be_blank); } } }); } } }); d.show(); return true; case R.id.btnRemoveRename: contextInfo = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo(); // the child view who's info we're viewing (should be equal to v) v = contextInfo.targetView; app_name = ((TextView) v.findViewById(R.id.tvPackage)).getText().toString(); viewHolder = (ListViewHolder) v.getTag(); if (viewHolder == null || viewHolder.chkEnabled == null) { if (Constants.IS_LOGGABLE) { Log.i(Constants.LOG_TAG, "Viewholder is null or chkEnabled is null"); } //failure return true; } package_name = (String) viewHolder.chkEnabled.getTag(); builder.setTitle( getString(R.string.dialog_title_remove_rename) + app_name + " (" + package_name + ")?"); builder.setPositiveButton(R.string.confirm, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (Constants.IS_LOGGABLE) { Log.i(Constants.LOG_TAG, "Before remove is: " + String.valueOf(arrayRenames.length())); } JSONArray tmp = new JSONArray(); try { for (int i = 0; i < arrayRenames.length(); i++) { if (!arrayRenames.getJSONObject(i).getString("pkg").equalsIgnoreCase(package_name)) { tmp.put(arrayRenames.getJSONObject(i)); } } } catch (JSONException e) { e.printStackTrace(); } arrayRenames = tmp; if (Constants.IS_LOGGABLE) { Log.i(Constants.LOG_TAG, "After remove is: " + String.valueOf(arrayRenames.length())); } ((packageAdapter) lvPackages.getAdapter()).notifyDataSetChanged(); } }); builder.setNegativeButton(R.string.decline, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { //do nothing } }); builder.show(); return true; } return super.onOptionsItemSelected(item); }
From source file:jp.watnow.plugins.dialog.Notification.java
/** * Builds and shows a native Android prompt dialog with given title, message, buttons. * This dialog only shows up to 3 buttons. Any labels after that will be ignored. * The following results are returned to the JavaScript callback identified by callbackId: * buttonIndex Index number of the button selected * input1 The text entered in the prompt dialog box * * @param message The message the dialog should display * @param title The title of the dialog * @param buttonLabels A comma separated list of button labels (Up to 3 buttons) * @param callbackContext The callback context. *//* w ww.j ava 2s . c o m*/ public synchronized void prompt(final String message, final String title, final JSONArray buttonLabels, final String defaultText, final String dialogType, final CallbackContext callbackContext) { final CordovaInterface cordova = this.cordova; Runnable runnable = new Runnable() { public void run() { final EditText promptInput = new EditText(cordova.getActivity()); promptInput.setHint(defaultText); Log.d("DialogPlugin", dialogType); if (dialogType.equals(INPUT_SECURE)) { promptInput.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD); } AlertDialog.Builder dlg = createDialog(cordova); // new AlertDialog.Builder(cordova.getActivity(), AlertDialog.THEME_DEVICE_DEFAULT_LIGHT); dlg.setMessage(message); dlg.setTitle(title); dlg.setCancelable(false); dlg.setView(promptInput); final JSONObject result = new JSONObject(); // First button if (buttonLabels.length() > 0) { try { dlg.setNegativeButton(buttonLabels.getString(0), new AlertDialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); try { result.put("buttonIndex", 1); result.put("input1", promptInput.getText().toString().trim().length() == 0 ? defaultText : promptInput.getText()); } catch (JSONException e) { e.printStackTrace(); } callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, result)); } }); } catch (JSONException e) { } } // Second button if (buttonLabels.length() > 1) { try { dlg.setNeutralButton(buttonLabels.getString(1), new AlertDialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); try { result.put("buttonIndex", 2); result.put("input1", promptInput.getText().toString().trim().length() == 0 ? defaultText : promptInput.getText()); } catch (JSONException e) { e.printStackTrace(); } callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, result)); } }); } catch (JSONException e) { } } // Third button if (buttonLabels.length() > 2) { try { dlg.setPositiveButton(buttonLabels.getString(2), new AlertDialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); try { result.put("buttonIndex", 3); result.put("input1", promptInput.getText().toString().trim().length() == 0 ? defaultText : promptInput.getText()); } catch (JSONException e) { e.printStackTrace(); } callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, result)); } }); } catch (JSONException e) { } } dlg.setOnCancelListener(new AlertDialog.OnCancelListener() { public void onCancel(DialogInterface dialog) { dialog.dismiss(); try { result.put("buttonIndex", 0); result.put("input1", promptInput.getText().toString().trim().length() == 0 ? defaultText : promptInput.getText()); } catch (JSONException e) { e.printStackTrace(); } callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, result)); } }); changeTextDirection(dlg); }; }; this.cordova.getActivity().runOnUiThread(runnable); }
From source file:org.thoughtland.xlocation.ActivityShare.java
@SuppressLint("InflateParams") public static boolean registerDevice(final ActivityBase context) { int userId = Util.getUserId(Process.myUid()); if (Util.hasProLicense(context) == null && !PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingRegistered, false)) { // Get accounts String email = null;/*w w w .j ava2 s. co m*/ for (Account account : AccountManager.get(context).getAccounts()) if ("com.google".equals(account.type)) { email = account.name; break; } LayoutInflater LayoutInflater = (LayoutInflater) context .getSystemService(Context.LAYOUT_INFLATER_SERVICE); View view = LayoutInflater.inflate(R.layout.register, null); final EditText input = (EditText) view.findViewById(R.id.etEmail); if (email != null) input.setText(email); // Build dialog AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(context); alertDialogBuilder.setTitle(R.string.msg_register); alertDialogBuilder.setIcon(context.getThemed(R.attr.icon_launcher)); alertDialogBuilder.setView(view); alertDialogBuilder.setPositiveButton(context.getString(android.R.string.ok), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { String email = input.getText().toString(); if (Patterns.EMAIL_ADDRESS.matcher(email).matches()) new RegisterTask(context).executeOnExecutor(mExecutor, email); } }); alertDialogBuilder.setNegativeButton(context.getString(android.R.string.cancel), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // Do nothing } }); // Show dialog AlertDialog alertDialog = alertDialogBuilder.create(); alertDialog.show(); return false; } return true; }
From source file:com.nextgis.mobile.map.RemoteTMSLayer.java
protected static void showPropertiesDialog(final MapBase map, final boolean bCreate, String layerName, String layerUrl, int type, final RemoteTMSLayer layer) { final LinearLayout linearLayout = new LinearLayout(map.getContext()); final EditText input = new EditText(map.getContext()); input.setText(layerName);/* w w w.ja v a 2s . c om*/ final EditText url = new EditText(map.getContext()); url.setText(layerUrl); final TextView stLayerName = new TextView(map.getContext()); stLayerName.setText(map.getContext().getString(R.string.layer_name) + ":"); final TextView stLayerUrl = new TextView(map.getContext()); stLayerUrl.setText(map.getContext().getString(R.string.layer_url) + ":"); final TextView stLayerType = new TextView(map.getContext()); stLayerType.setText(map.getContext().getString(R.string.layer_type) + ":"); final ArrayAdapter<CharSequence> adapter = new ArrayAdapter<CharSequence>(map.getContext(), android.R.layout.simple_spinner_item); final Spinner spinner = new Spinner(map.getContext()); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner.setAdapter(adapter); adapter.add(map.getContext().getString(R.string.tmstype_osm)); adapter.add(map.getContext().getString(R.string.tmstype_normal)); adapter.add(map.getContext().getString(R.string.tmstype_ngw)); if (type == TMSTYPE_OSM) { spinner.setSelection(0); } else { spinner.setSelection(1); } linearLayout.setOrientation(LinearLayout.VERTICAL); linearLayout.addView(stLayerName); linearLayout.addView(input); linearLayout.addView(stLayerUrl); linearLayout.addView(url); linearLayout.addView(stLayerType); linearLayout.addView(spinner); new AlertDialog.Builder(map.getContext()) .setTitle(bCreate ? R.string.input_layer_properties : R.string.change_layer_properties) // .setMessage(message) .setView(linearLayout).setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { int tmsType = 0; switch (spinner.getSelectedItemPosition()) { case 0: case 1: tmsType = TMSTYPE_OSM; break; case 2: case 3: tmsType = TMSTYPE_NORMAL; break; } if (bCreate) { create(map, input.getText().toString(), url.getText().toString(), tmsType); } else { layer.setName(input.getText().toString()); layer.setTMSType(tmsType); map.onLayerChanged(layer); } } }).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { // Do nothing. Toast.makeText(map.getContext(), R.string.error_cancel_by_user, Toast.LENGTH_SHORT).show(); } }).show(); }
From source file:at.flack.MailMainActivity.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { prefs = getActivity().getSharedPreferences("mail", Context.MODE_PRIVATE); if (!prefs.getString("mailaddress", "").equals("")) { View rootView = inflater.inflate(R.layout.fragment_mail_main, container, false); loadmore = new LoadMoreAdapter(inflater.inflate(R.layout.contacts_loadmore, contactList, false)); contactList = (ListView) rootView.findViewById(R.id.listview); TextView padding = new TextView(getActivity()); padding.setHeight(10);/* w ww. java 2 s . c o m*/ contactList.addHeaderView(padding); contactList.setHeaderDividersEnabled(false); contactList.addFooterView(loadmore.getView(), null, false); contactList.setFooterDividersEnabled(false); progressbar = rootView.findViewById(R.id.load_screen); FloatingActionButton fab = (FloatingActionButton) rootView.findViewById(R.id.fab); fab.attachToListView(contactList); fab.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { Intent newMail = new Intent(getActivity(), NewMailActivity.class); getActivity().startActivity(newMail); } }); progressbar = rootView.findViewById(R.id.load_screen); if (MainActivity.getMailcontacts() == null) progressbar.setVisibility(View.VISIBLE); updateContactList(((MainActivity) this.getActivity())); swipe = (SwipeRefreshLayout) rootView.findViewById(R.id.swipe_container); swipe.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { @Override public void onRefresh() { if (getActivity() instanceof MainActivity) { MainActivity.mailprofile = null; ((MainActivity) getActivity()).emailLogin(1, 0, limit); } } }); contactList.setOnScrollListener(new AbsListView.OnScrollListener() { @Override public void onScrollStateChanged(AbsListView view, int scrollState) { } @Override public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { int topRowVerticalPosition = (contactList == null || contactList.getChildCount() == 0) ? 0 : contactList.getChildAt(0).getTop(); swipe.setEnabled(topRowVerticalPosition >= 0); } }); contactList.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) { if (MainActivity.getListItems() == null) { updateContactList((MainActivity) getActivity()); } openMessageActivity(getActivity(), arg2 - 1); } }); loadmore.getView().setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { loadmore.setEnabled(false); MainActivity.mailprofile = null; limit += 12; ((MainActivity) getActivity()).emailLogin(1, 0, limit); } }); setRetainInstance(true); return rootView; } else { View rootView = inflater.inflate(R.layout.fragment_email_login, container, false); final EditText mail = (EditText) rootView.findViewById(R.id.email); final EditText password = (EditText) rootView.findViewById(R.id.password); final EditText host = (EditText) rootView.findViewById(R.id.host); final EditText port = (EditText) rootView.findViewById(R.id.port); final EditText smtphost = (EditText) rootView.findViewById(R.id.smtphost); final EditText smtpport = (EditText) rootView.findViewById(R.id.smtpport); final Button login_button = (Button) rootView.findViewById(R.id.login_button); final RadioGroup radioGroup = (RadioGroup) rootView.findViewById(R.id.radioGroup); final RadioButton imap = (RadioButton) rootView.findViewById(R.id.radioButtonImap); radioGroup.setOnCheckedChangeListener(new OnCheckedChangeListener() { public void onCheckedChanged(RadioGroup group, int checkedId) { host.setVisibility(View.VISIBLE); port.setVisibility(View.VISIBLE); smtphost.setVisibility(View.VISIBLE); smtpport.setVisibility(View.VISIBLE); } }); login_button.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { int at = mail.getText().toString().indexOf("@"); int dot = mail.getText().toString().lastIndexOf("."); if (mail.getText().length() <= 0 || at < 0 || dot < 0) { Toast.makeText(MailMainActivity.this.getActivity(), getResources().getString(R.string.facebook_login_please_enter_valid_mail), Toast.LENGTH_SHORT).show(); return; } if (password.getText().length() <= 0) { Toast.makeText(MailMainActivity.this.getActivity(), getResources().getString(R.string.facebook_login_please_enter_valid_pw), Toast.LENGTH_SHORT).show(); return; } String hostPart = mail.getText().toString().substring(at + 1, dot); MailAccounts mailacc = null; try { mailacc = MailAccounts.valueOf(hostPart.toUpperCase(Locale.GERMAN)); } catch (IllegalArgumentException e) { } if (mailacc == null) { radioGroup.setVisibility(View.VISIBLE); if (host.getText().toString().isEmpty() || port.getText().toString().isEmpty() || smtphost.getText().toString().isEmpty() || smtpport.getText().toString().isEmpty()) { Toast.makeText(MailMainActivity.this.getActivity(), MailMainActivity.this.getActivity().getResources().getString( R.string.activity_mail_enter_more_information), Toast.LENGTH_LONG).show(); return; } prefs.edit().putString("mailsmtp", smtphost.getText().toString()).apply(); prefs.edit().putInt("mailsmtpport", Integer.parseInt(smtpport.getText().toString())); prefs.edit().putString("mailimap", host.getText().toString()).apply(); prefs.edit().putInt("mailimapport", Integer.parseInt(port.getText().toString())).apply(); prefs.edit().putBoolean("mailuseimap", imap.isChecked()).apply(); } login_button.setEnabled(false); login_button.getBackground().setColorFilter(Color.GRAY, PorterDuff.Mode.MULTIPLY); prefs.edit().putString("mailaddress", mail.getText().toString()).apply(); prefs.edit().putString("mailpassword", password.getText().toString()).apply(); if (mailacc != null) { prefs.edit().putString("mailsmtp", mailacc.getSmtpHost()).apply(); prefs.edit().putInt("mailsmtpport", mailacc.getSMTPPort()); prefs.edit().putString("mailimap", mailacc.getHost()).apply(); prefs.edit().putInt("mailimapport", mailacc.getPort()).apply(); prefs.edit().putBoolean("mailuseimap", true).apply(); } prefs.edit().commit(); ((MainActivity) getActivity()).emailLogin(0); } }); setRetainInstance(true); return rootView; } }
From source file:com.kncwallet.wallet.ui.WalletActivity.java
private Dialog createImportKeysDialog() { final View view = getLayoutInflater().inflate(R.layout.import_keys_from_storage_dialog, null); final Spinner fileView = (Spinner) view.findViewById(R.id.import_keys_from_storage_file); final EditText passwordView = (EditText) view.findViewById(R.id.import_keys_from_storage_password); final KnCDialog.Builder builder = new KnCDialog.Builder(this); builder.setInverseBackgroundForced(true); builder.setTitle(R.string.import_keys_dialog_title); builder.setView(view);//from www . j a v a2 s . com builder.setPositiveButton(R.string.import_keys_dialog_button_import, new OnClickListener() { @Override public void onClick(final DialogInterface dialog, final int which) { final File file = (File) fileView.getSelectedItem(); final String password = passwordView.getText().toString().trim(); passwordView.setText(null); // get rid of it asap importPrivateKeys(file, password); } }); builder.setNegativeButton(R.string.button_cancel, new OnClickListener() { @Override public void onClick(final DialogInterface dialog, final int which) { passwordView.setText(null); // get rid of it asap } }); builder.setOnCancelListener(new OnCancelListener() { @Override public void onCancel(final DialogInterface dialog) { passwordView.setText(null); // get rid of it asap } }); return builder.create(); }
From source file:com.entertailion.android.launcher.Dialogs.java
/** * Display dialog to allow user to add an app to a row. The user can add the * app to an existing row or a new row.// w w w . j a va 2 s .co m * * @param context * @param applications */ public static void displayAddApps(final Launcher context, final ArrayList<ApplicationInfo> applications) { final Dialog dialog = new Dialog(context); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setContentView(R.layout.add_apps_grid); final EditText nameEditText = (EditText) dialog.findViewById(R.id.rowName); final RadioButton currentRadioButton = (RadioButton) dialog.findViewById(R.id.currentRadio); currentRadioButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // hide the row name edit field if the current row radio button // is selected nameEditText.setVisibility(View.GONE); } }); final RadioButton newRadioButton = (RadioButton) dialog.findViewById(R.id.newRadio); newRadioButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // show the row name edit field if the new radio button is // selected nameEditText.setVisibility(View.VISIBLE); nameEditText.requestFocus(); } }); final GridView gridView = (GridView) dialog.findViewById(R.id.grid); gridView.setAdapter(new AllItemAdapter(context, getApplications(context, applications, true))); gridView.setOnItemClickListener(new android.widget.AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { // if the new row radio button is selected, the user must enter // a name for the new row String name = nameEditText.getText().toString().trim(); if (newRadioButton.isChecked() && name.length() == 0) { nameEditText.requestFocus(); displayAlert(context, context.getString(R.string.dialog_new_row_name_alert)); return; } ItemInfo itemInfo = (ItemInfo) parent.getAdapter().getItem(position); boolean currentRow = !newRadioButton.isChecked(); context.addItem(itemInfo, currentRow ? null : name); context.showCover(false); dialog.dismiss(); if (currentRow) { Analytics.logEvent(Analytics.DIALOG_ADD_APP); } else { Analytics.logEvent(Analytics.ADD_APP_WITH_ROW); } } }); gridView.setDrawingCacheEnabled(true); gridView.setOnKeyListener(onKeyListener); dialog.setOnDismissListener(new OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) { context.showCover(false); } }); context.showCover(true); dialog.show(); Analytics.logEvent(Analytics.DIALOG_ADD_APP); }
From source file:com.example.devesh.Coride.DriverRegistration.java
@TargetApi(Build.VERSION_CODES.M) public void sendData(View view) throws MalformedURLException { Log.e("TEST LOG", "Entered the loop"); Toast.makeText(this, "coride", Toast.LENGTH_SHORT).show(); Master master = new Master(); String url_string = master.url + "driverdata"; EditText n_edittext; EditText mob_edittext;/*from www. j a v a 2 s.co m*/ EditText confrm_edittext; EditText age_edittext; EditText lnumber; EditText pnumber; EditText vnumber; EditText mnumber; EditText capacity; String name; String mobile; String conpassword; String password; String address; String email; String slnumber; String spnumber; String svnumber; String smnumber; String scapacity; int count = 0; n_edittext = (EditText) findViewById(R.id.name); mob_edittext = (EditText) findViewById(R.id.mobileno); confrm_edittext = (EditText) findViewById(R.id.confirmpassword); mPasswordView = (EditText) findViewById(R.id.password); mEmailView = (AutoCompleteTextView) findViewById(R.id.email); age_edittext = (EditText) findViewById(R.id.address); lnumber = (EditText) findViewById(R.id.lnumber); pnumber = (EditText) findViewById(R.id.pnumber); vnumber = (EditText) findViewById(R.id.vnumber); mnumber = (EditText) findViewById(R.id.mnumber); capacity = (EditText) findViewById(R.id.capacity); name = n_edittext.getText().toString(); mobile = mob_edittext.getText().toString(); master.mobile1 = mobile; password = mPasswordView.getText().toString(); conpassword = confrm_edittext.getText().toString(); address = age_edittext.getText().toString(); email = mEmailView.getText().toString(); slnumber = lnumber.getText().toString(); spnumber = pnumber.getText().toString(); svnumber = vnumber.getText().toString(); smnumber = mnumber.getText().toString(); ; scapacity = capacity.getText().toString(); regId = registerGCM(); System.out.println(regId); // String reg=regId.toString(); count = validate(name, email, mobile, password, conpassword, address); if (count == 0) { count = email_validation(mEmailView, getBaseContext()); } if (count == 0) { count = password_matcher(password, conpassword); } if (count == 0) { String json = "[{name:\"" + name + "\"},{mobile:\"" + mobile + "\"},{password:\"" + password + "\"},{email:\"" + email + "\"},{address:\"" + address + "\"},{license:\"" + slnumber + "\"},{pan:\"" + spnumber + "\"},{vehicle:\"" + svnumber + "\"},{model:\"" + smnumber + "\"},{capacity:\"" + scapacity + "\"},{regid:\"" + regId + "\"}]"; // snd.addNameValuePair("name", name); //snd.addNameValuePair("mobile", mobile); //snd.addNameValuePair("password", password); // snd.addNameValuePair("email",email); //snd.addNameValuePair("age", age); SendDataTask snd = new SendDataTask(json); //Go to sendData class fromhere URL url = new URL(url_string); snd.execute(url); } System.out.println("i am hear"); LocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); if (locationManager.isProviderEnabled(locationManager.NETWORK_PROVIDER) || locationManager.isProviderEnabled(locationManager.GPS_PROVIDER)) { Log.e("Coride", "Provider enable"); callLocationService(); } else { Log.e("Coride", "provider disabled"); showSettingsAlert("NETWORK_PROVIDER"); } LocationListener locationListener = new LocationListener() { @Override public void onLocationChanged(Location location) { } @Override public void onStatusChanged(String s, int i, Bundle bundle) { } @Override public void onProviderEnabled(String s) { callLocationService(); } @Override public void onProviderDisabled(String s) { showSettingsAlert("NETWORK_PROVIDER"); } }; // dialog.cancel(); if (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) { requestPermissions(new String[] { Manifest.permission.ACCESS_FINE_LOCATION }, 123); return; } locationManager.requestLocationUpdates(locationManager.NETWORK_PROVIDER, 0, 0, locationListener); }