List of usage examples for android.widget EditText getText
@Override
public Editable getText()
From source file:fr.univsavoie.ltp.client.MainActivity.java
/** * Geocoding of the destination address/* w w w . j av a 2s. c o m*/ */ public void handleSearchLocationButton() { EditText destinationEdit = (EditText) findViewById(R.id.editDestination); //Hide the soft keyboard: InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(destinationEdit.getWindowToken(), 0); String destinationAddress = destinationEdit.getText().toString(); GeocoderNominatim geocoder = new GeocoderNominatim(this); try { List<Address> foundAdresses = geocoder.getFromLocationName(destinationAddress, 1); if (foundAdresses.size() == 0) { //if no address found, display an error Toast.makeText(this, R.string.toast_address, Toast.LENGTH_SHORT).show(); } else { Address address = foundAdresses.get(0); //get first address destinationPoint = new GeoPoint(address.getLatitude(), address.getLongitude()); markerDestination = putMarkerItem(markerDestination, destinationPoint, DEST_INDEX, R.string.destination, R.drawable.marker_destination, -1); getRoadAsync(); map.getController().setCenter(destinationPoint); } } catch (Exception e) { Toast.makeText(this, R.string.toast_geocode, Toast.LENGTH_SHORT).show(); } }
From source file:com.ximai.savingsmore.save.activity.AddGoodsAcitivyt.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.add_good_activity); setCenterTitle("?"); setLeftBackMenuVisibility(AddGoodsAcitivyt.this, ""); head_view = (ImageView) findViewById(R.id.head_image); my_name = (TextView) findViewById(R.id.name); MyImageLoader.displayDefaultImage(URLText.img_url + MyUserInfoUtils.getInstance().myUserInfo.PhotoPath, head_view);/*from w w w . j av a 2 s . c o m*/ if (null != MyUserInfoUtils.getInstance().myUserInfo.UserExtInfo) { my_name.setText(MyUserInfoUtils.getInstance().myUserInfo.UserExtInfo.StoreName); } cuxiaoshuoming = (TextView) findViewById(R.id.cuxiaoshuoming); shangpingmiaoshu = (TextView) findViewById(R.id.shangpingmiaoshu); horizontalListView = (HorizontalListView) findViewById(R.id.myGridview); yijifenlei = (TextView) findViewById(R.id.one_classity); erjifenlei = (TextView) findViewById(R.id.two_classity); brand = (TextView) findViewById(R.id.brand_name); xingshi_item = (LinearLayout) findViewById(R.id.xingshi_item); xingshi = (TextView) findViewById(R.id.xingshi); yuanyin_item = (LinearLayout) findViewById(R.id.yuanyin_item); yuanyin = (TextView) findViewById(R.id.yuanyin); dizhi_item = (LinearLayout) findViewById(R.id.dizhi_item); dizhi = (TextView) findViewById(R.id.dizhi); satrt_item = (LinearLayout) findViewById(R.id.start_time_item); start = (TextView) findViewById(R.id.start_time); end_item = (LinearLayout) findViewById(R.id.end_time_item); end = (TextView) findViewById(R.id.end_time); danwei_item = (LinearLayout) findViewById(R.id.danwei_item); danwei = (TextView) findViewById(R.id.danwei); bizhong_item = (LinearLayout) findViewById(R.id.bizhong_item); bizhong = (TextView) findViewById(R.id.bizhong); fapiao_item = (LinearLayout) findViewById(R.id.fapiao_item); fapiao = (TextView) findViewById(R.id.fapiao); yuan_price = (EditText) findViewById(R.id.yuan_price); cuxiao_price = (EditText) findViewById(R.id.cuxiao_price); cuxiao_text = (TextView) findViewById(R.id.cuxiao_text); fabu = (TextView) findViewById(R.id.fabu); product_bianhao = (EditText) findViewById(R.id.product_bianhao); product_name = (EditText) findViewById(R.id.product_name); xiangxi_address = (EditText) findViewById(R.id.xiangxi_address); servise = (TextView) findViewById(R.id.servise); servise.setOnClickListener(this); fabu.setOnClickListener(this); yijifenlei.setOnClickListener(this); erjifenlei.setOnClickListener(this); brand.setOnClickListener(this); xingshi_item.setOnClickListener(this); yuanyin_item.setOnClickListener(this); dizhi_item.setOnClickListener(this); satrt_item.setOnClickListener(this); end_item.setOnClickListener(this); danwei_item.setOnClickListener(this); bizhong_item.setOnClickListener(this); fapiao_item.setOnClickListener(this); yuan_price.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } @Override public void afterTextChanged(Editable s) { if (null != xingshi_id) { if (xingshi_id.equals("2") || xingshi_id.equals("3") || xingshi_id.equals("7") || xingshi_id.equals("12")) { cuxiao_price.setText(s.toString()); } } } }); myAdapter = new MyAdapter(); horizontalListView.setAdapter(myAdapter); queryDicNode(); queryDicNode2(); explain = (EditText) findViewById(R.id.explain); descript = (EditText) findViewById(R.id.decript); shuoming_number = explain.getText().length(); miaoshu_number = descript.getText().length(); explain.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { shuoming_number = explain.getText().length(); cuxiaoshuoming.setText("(?" + (200 - shuoming_number) + ")"); } @Override public void afterTextChanged(Editable s) { } }); descript.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { miaoshu_number = descript.getText().length(); shangpingmiaoshu.setText("???(?" + (200 - miaoshu_number) + ")"); } @Override public void afterTextChanged(Editable s) { } }); zidingyi_brand = (TextView) findViewById(R.id.zidingyi_brand); custom_type = (TextView) findViewById(R.id.custom_type); zidingyi_brand.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { classity_dialog = new AlertDialog.Builder(AddGoodsAcitivyt.this).create(); View view = LayoutInflater.from(AddGoodsAcitivyt.this).inflate(R.layout.save_brand, null); final TextView queding, quxiao; final EditText content; queding = (TextView) view.findViewById(R.id.comfirm); quxiao = (TextView) view.findViewById(R.id.cannel); content = (EditText) view.findViewById(R.id.content); queding.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (null != content.getText() && !TextUtils.isEmpty(content.getText())) { save_brand(content.getText().toString()); } } }); quxiao.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { classity_dialog.dismiss(); } }); classity_dialog.setView(view); classity_dialog.show(); } }); custom_type.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (oneId != null && !TextUtils.isEmpty(oneId)) { brand_dialog = new AlertDialog.Builder(AddGoodsAcitivyt.this).create(); View view = LayoutInflater.from(AddGoodsAcitivyt.this).inflate(R.layout.custom_classfy, null); final TextView queding, quxiao; final EditText content; queding = (TextView) view.findViewById(R.id.comfirm); quxiao = (TextView) view.findViewById(R.id.cannel); content = (EditText) view.findViewById(R.id.content); queding.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (null != content.getText() && !TextUtils.isEmpty(content.getText())) { apply_calssity(content.getText().toString(), oneId); } } }); quxiao.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { brand_dialog.dismiss(); } }); brand_dialog.setView(view); brand_dialog.show(); } else { Toast.makeText(AddGoodsAcitivyt.this, "", Toast.LENGTH_SHORT).show(); } } }); cuxiao_price.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (cuxiao_text.getText().equals("N?N")) { bug_dialog = new AlertDialog.Builder(AddGoodsAcitivyt.this).create(); View view = LayoutInflater.from(AddGoodsAcitivyt.this).inflate(R.layout.bug_give, null); final TextView queding, quxiao; final EditText number1, number2; queding = (TextView) view.findViewById(R.id.comfirm); quxiao = (TextView) view.findViewById(R.id.cannel); number1 = (EditText) view.findViewById(R.id.number1); number2 = (EditText) view.findViewById(R.id.number2); queding.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (null != number1.getText() && !TextUtils.isEmpty(number1.getText()) && null != number2.getText() && !TextUtils.isEmpty(number2.getText())) { cuxiao_price.setText("" + number1.getText().toString() + "?" + number2.getText().toString()); bug_dialog.dismiss(); } } }); quxiao.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { bug_dialog.dismiss(); } }); bug_dialog.setView(view); bug_dialog.show(); } } }); myProduct = new MyProduct(); if (null != getIntent().getStringExtra("id")) { Id = getIntent().getStringExtra("id"); getgood_detial(Id); } }
From source file:in.shick.diode.mail.InboxListActivity.java
@Override protected Dialog onCreateDialog(int id) { Dialog dialog;// ww w . ja v a2 s .co m ProgressDialog pdialog; switch (id) { case Constants.DIALOG_LOGIN: dialog = new LoginDialog(this, mSettings, true) { @Override public void onLoginChosen(String user, String password) { removeDialog(Constants.DIALOG_LOGIN); new MyLoginTask(user, password).execute(); } }; break; case Constants.DIALOG_REPLY: dialog = new Dialog(this, mSettings.getDialogTheme()); dialog.setContentView(R.layout.compose_reply_dialog); final EditText replyBody = (EditText) dialog.findViewById(R.id.body); final Button replySaveButton = (Button) dialog.findViewById(R.id.reply_save_button); final Button replyCancelButton = (Button) dialog.findViewById(R.id.reply_cancel_button); replySaveButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { if (mReplyTargetName != null) { new MessageReplyTask(mReplyTargetName).execute(replyBody.getText().toString()); removeDialog(Constants.DIALOG_REPLY); } else { Common.showErrorToast("Error replying. Please try again.", Toast.LENGTH_SHORT, InboxListActivity.this); } } }); replyCancelButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { removeDialog(Constants.DIALOG_REPLY); } }); break; // "Please wait" case Constants.DIALOG_LOGGING_IN: pdialog = new ProgressDialog(new ContextThemeWrapper(this, mSettings.getDialogTheme())); pdialog.setMessage("Logging in..."); pdialog.setIndeterminate(true); pdialog.setCancelable(true); dialog = pdialog; break; case Constants.DIALOG_REPLYING: pdialog = new ProgressDialog(new ContextThemeWrapper(this, mSettings.getDialogTheme())); pdialog.setMessage("Sending reply..."); pdialog.setIndeterminate(true); pdialog.setCancelable(true); dialog = pdialog; break; default: throw new IllegalArgumentException("Unexpected dialog id " + id); } return dialog; }
From source file:com.orange.datavenue.ValueFragment.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.action_add_value: /**/*from w ww . j ava 2s . co m*/ * Add value */ mDialog = new android.app.Dialog(getActivity()); mDialog.setContentView(R.layout.create_value_dialog); mDialog.setTitle(R.string.add_value); final EditText at = (EditText) mDialog.findViewById(R.id.at); final EditText metadata = (EditText) mDialog.findViewById(R.id.metadata); final EditText latitude = (EditText) mDialog.findViewById(R.id.latitude); final EditText longitude = (EditText) mDialog.findViewById(R.id.longitude); final EditText value = (EditText) mDialog.findViewById(R.id.value); SimpleDateFormat ISO8601DATEFORMAT = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ"); Date now = new Date(); at.setText(ISO8601DATEFORMAT.format(now)); Button addButton = (Button) mDialog.findViewById(R.id.add_button); addButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Log.d(TAG_NAME, "at : " + at.getText().toString()); Log.d(TAG_NAME, "metadata : " + metadata.getText().toString()); Log.d(TAG_NAME, "value : " + value.getText().toString()); Value newValue = new Value(); newValue.setAt(at.getText().toString()); Double[] location = null; String strLatitude = latitude.getText().toString(); String strLongitude = longitude.getText().toString(); try { if ((!"".equals(strLatitude)) && (!"".equals(strLongitude))) { location = new Double[2]; location[0] = Double.parseDouble(strLatitude); location[1] = Double.parseDouble(strLongitude); } } catch (NumberFormatException e) { Log.e(TAG_NAME, e.toString()); location = null; } newValue.setLocation(location); if (!"".equals(value.getText().toString())) { try { JSONObject valueJson = (JSONObject) new JSONParser().parse(value.getText().toString()); newValue.setValue(valueJson); } catch (ParseException e) { Log.e(TAG_NAME, e.toString()); newValue.setValue(value.getText().toString()); } catch (ClassCastException ce) { Log.e(TAG_NAME, ce.toString()); newValue.setValue(value.getText().toString()); } } else { newValue.setValue(null); } if (!"".equals(metadata.getText().toString())) { try { JSONObject metadataJson = (JSONObject) new JSONParser() .parse(metadata.getText().toString()); newValue.setMetadata(metadataJson); } catch (ParseException e) { Log.e(TAG_NAME, e.toString()); newValue.setMetadata(metadata.getText().toString()); } catch (ClassCastException ce) { Log.e(TAG_NAME, ce.toString()); newValue.setMetadata(metadata.getText().toString()); } } else { newValue.setMetadata(null); } CreateValueOperation createValueOperation = new CreateValueOperation(Model.instance.oapiKey, Model.instance.key, Model.instance.currentDatasource, Model.instance.currentStream, newValue, new OperationCallback() { @Override public void process(Object object, Exception exception) { if (exception == null) { mPageNumber = 1; getValues(mPageNumber, true); } else { Errors.displayError(getActivity(), exception); } } }); createValueOperation.execute(""); mDialog.dismiss(); } }); Button cancelButton = (Button) mDialog.findViewById(R.id.cancel_button); cancelButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { mDialog.dismiss(); } }); mDialog.setCancelable(false); mDialog.show(); return true; case R.id.action_add_sensor_sensor: /** * Geolocation */ mDialog = new android.app.Dialog(getActivity()); mDialog.setContentView(R.layout.add_sensor_value_dialog); mDialog.setTitle(R.string.geolocation); llInfo = (LinearLayout) mDialog.findViewById(R.id.info); llValue = (LinearLayout) mDialog.findViewById(R.id.value); llValue.setVisibility(View.GONE); tvLatitude = (TextView) mDialog.findViewById(R.id.latitude); tvLongitude = (TextView) mDialog.findViewById(R.id.longitude); if (mLocationService != null) { mLocationService.setServiceParameters(Model.instance.oapiKey, Model.instance.key, Model.instance.currentDatasource, Model.instance.currentStream); mLocationService.register(this); mLocationService.start(); } Button cButton = (Button) mDialog.findViewById(R.id.cancel_button); cButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (mLocationService != null) { mLocationService.stop(); } tvLatitude = null; tvLongitude = null; mDialog.dismiss(); } }); mDialog.setCancelable(false); mDialog.show(); return true; default: break; } return false; }
From source file:com.andrewshu.android.reddit.mail.InboxListActivity.java
@Override protected Dialog onCreateDialog(int id) { Dialog dialog;//from w w w .j a v a 2 s . c om ProgressDialog pdialog; AlertDialog.Builder builder; LayoutInflater inflater; View layout; // used for inflated views for AlertDialog.Builder.setView() switch (id) { case Constants.DIALOG_LOGIN: dialog = new LoginDialog(this, mSettings, true) { @Override public void onLoginChosen(String user, String password) { removeDialog(Constants.DIALOG_LOGIN); new MyLoginTask(user, password).execute(); } }; break; case Constants.DIALOG_REPLY: dialog = new Dialog(this, mSettings.getDialogTheme()); dialog.setContentView(R.layout.compose_reply_dialog); final EditText replyBody = (EditText) dialog.findViewById(R.id.body); final Button replySaveButton = (Button) dialog.findViewById(R.id.reply_save_button); final Button replyCancelButton = (Button) dialog.findViewById(R.id.reply_cancel_button); replySaveButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { if (mReplyTargetName != null) { new MessageReplyTask(mReplyTargetName).execute(replyBody.getText().toString()); removeDialog(Constants.DIALOG_REPLY); } else { Common.showErrorToast("Error replying. Please try again.", Toast.LENGTH_SHORT, InboxListActivity.this); } } }); replyCancelButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { removeDialog(Constants.DIALOG_REPLY); } }); break; // "Please wait" case Constants.DIALOG_LOGGING_IN: pdialog = new ProgressDialog(new ContextThemeWrapper(this, mSettings.getDialogTheme())); pdialog.setMessage("Logging in..."); pdialog.setIndeterminate(true); pdialog.setCancelable(true); dialog = pdialog; break; case Constants.DIALOG_REPLYING: pdialog = new ProgressDialog(new ContextThemeWrapper(this, mSettings.getDialogTheme())); pdialog.setMessage("Sending reply..."); pdialog.setIndeterminate(true); pdialog.setCancelable(true); dialog = pdialog; break; default: throw new IllegalArgumentException("Unexpected dialog id " + id); } return dialog; }
From source file:edu.mum.ml.group7.guessasketch.android.EasyPaint.java
public void refreshLabels(JSONObject jObject) { /* Button btn = new Button(this); btn.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, getResources().getDimensionPixelSize(R.dimen.prediction_text_view_height) )); btn.setTextSize(pixels);/*from w ww . j a v a 2 s .c om*/ btn.setText("Cat"); predictions.addView(btn); */ final List<RadioButton> buttons = new ArrayList<>(); String result = "I think it's: "; try { JSONArray jArray = jObject.getJSONArray("data"); for (int i = 0; i < jArray.length(); i++) { JSONObject prediction = jArray.getJSONObject(i); // Pulling items from the array int score = prediction.getInt("score"); if (score < Constants.minScoreThershold) { continue; } String label = prediction.getString("label"); result += "\"" + label + "\" : " + score + "% "; RadioButton radioButton = new RadioButton(EasyPaint.this); radioButton.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, getResources().getDimensionPixelSize(R.dimen.prediction_text_view_height))); radioButton.setTextSize(pixels5); radioButton.setText(label + " (" + score + "%)"); radioButton.setTag(label); //radioButton.set //predictions.addView(radioButton); radioButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { saveButton.setTag(view.getTag()); feedbackType = ApiCallType.POSITIVE_FEEDBACK; } }); buttons.add(radioButton); } } catch (JSONException e) { e.printStackTrace(); } final RadioButton radioButton = new RadioButton(EasyPaint.this); radioButton.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, getResources().getDimensionPixelSize(R.dimen.prediction_text_view_height))); radioButton.setTextSize(pixels5); radioButton.setText(R.string.other_label); buttons.add(radioButton); radioButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { AlertDialog.Builder builder = new AlertDialog.Builder(EasyPaint.this); builder.setTitle(R.string.other_label); // Set up the input final EditText input = new EditText(EasyPaint.this); // Specify the type of input expected; this, for example, sets the input as a password, and will mask the text input.setInputType(InputType.TYPE_CLASS_TEXT); builder.setView(input); // Set up the buttons builder.setPositiveButton("OK", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (input.getText().toString().length() > 0) { radioButton.setText(input.getText().toString()); saveButton.setTag(input.getText().toString()); feedbackType = ApiCallType.NEGATIVE_FEEDBACK; } else { EasyPaint.this.runOnUiThread(new Runnable() { public void run() { Toast.makeText(getApplicationContext(), "You didn't specify a name, try again please", Toast.LENGTH_LONG) .show(); } }); saveButton.setTag(""); feedbackType = ApiCallType.POSITIVE_FEEDBACK; dialog.cancel(); } } }); builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { saveButton.setTag(""); feedbackType = ApiCallType.POSITIVE_FEEDBACK; dialog.cancel(); } }); builder.show(); } }); saveButton.setOnClickListener(otherLabelOnClickListener); toastMessage = result; EasyPaint.this.runOnUiThread(new Runnable() { public void run() { resetPredictionsView(predictions, false); Toast.makeText(getApplicationContext(), toastMessage, Toast.LENGTH_LONG).show(); for (RadioButton r : buttons) { predictions.addView(r); } } }); }
From source file:com.piusvelte.taplock.client.core.TapLockSettings.java
protected void setPassphrase(final int deviceIdx) { final EditText fld_passphrase = new EditText(TapLockSettings.this); // parse the existing passphrase JSONObject deviceJObj = mDevices.get(deviceIdx); try {/*from w w w . j av a2 s. c om*/ fld_passphrase.setText(deviceJObj.getString(KEY_PASSPHRASE)); } catch (JSONException e) { Log.e(TAG, e.getMessage()); } mDialog = new AlertDialog.Builder(TapLockSettings.this).setTitle("set passphrase").setView(fld_passphrase) .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); String passphrase = fld_passphrase.getText().toString(); JSONObject deviceJObj = mDevices.remove(deviceIdx); try { deviceJObj.put(KEY_PASSPHRASE, passphrase); } catch (JSONException e) { Log.e(TAG, e.getMessage()); } mDevices.add(deviceIdx, deviceJObj); if (mServiceInterface != null) { try { mServiceInterface.write(deviceJObj.getString(KEY_ADDRESS), ACTION_PASSPHRASE, passphrase); } catch (RemoteException e) { Log.e(TAG, e.getMessage()); } catch (JSONException e) { Log.e(TAG, e.getMessage()); } } else storeDevices(); } }).create(); mDialog.show(); }
From source file:com.example.pyrkesa.frag.User_Fragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { setRetainInstance(true);/*from ww w . j a va2 s .c o m*/ rootView = inflater.inflate(R.layout.user_fragment, container, false); userList = (ListView) rootView.findViewById(R.id.lt_user); // custom dialog final Dialog dialog = new Dialog(rootView.getContext()); d = dialog; userIcons = getResources().obtainTypedArray(R.array.userIcons);// load icons from userIcons1 = getResources().obtainTypedArray(R.array.userIcons1); userItems = new ArrayList<UserItem>(); adapter = new UserAdapter(getActivity(), userItems, getActivity()); userList.setAdapter(adapter); ImageButton addButton = (ImageButton) rootView.findViewById(R.id.add); addButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { ModelFactory model = (ModelFactory) ModelFactory.getContext(); if (model.user.type == 1) { dialog.setContentView(R.layout.adduser_dialog); dialog.setTitle("Ajouter un utilisateur "); dialogTypes = getResources().getStringArray(R.array.user_type_dialog); // load Button dialogButtonOk = (Button) dialog.findViewById(R.id.button_ok); Button dialogButtonCancel = (Button) dialog.findViewById(R.id.button_cancel); final EditText Newlogin = (EditText) dialog.findViewById(R.id.dialogLogin); final EditText NewPW = (EditText) dialog.findViewById(R.id.dialogPW); final Spinner NewType = (Spinner) dialog.findViewById(R.id.dialogType); ArrayList<String> types = new ArrayList<String>(); for (String t : dialogTypes) { types.add(t); } NewType.setAdapter(new ArrayAdapter<String>(rootView.getContext(), android.R.layout.simple_spinner_dropdown_item, types)); dialogButtonCancel.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dialog.dismiss(); } }); dialogButtonOk.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { ArrayList<String> temp = new ArrayList<String>(); String login = Newlogin.getText().toString(); String password = NewPW.getText().toString(); String type = NewType.getSelectedItem().toString(); if (login.equalsIgnoreCase("") && password.equalsIgnoreCase("") && type != null) { new AlertDialog.Builder(v.getContext()).setTitle("Attention") .setMessage("Veuillez remplir toutes les informations.").show(); } else { temp.add(login); temp.add(password); if (type.equalsIgnoreCase("admin")) { temp.add("1"); } else if (type.equalsIgnoreCase("utilisateur")) { temp.add("0"); } else { temp.add("0"); } } new addUser().execute(temp); } }); dialog.show(); } else { new AlertDialog.Builder(v.getContext()).setTitle("Attention") .setMessage("Opration interdite : Droits d'administration requis.").show(); } } }); // adding user items new LoadAllUser().execute(); return rootView; }
From source file:bikebadger.RideFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { Log.d(Constants.APP.TAG, "RideFragment.onCreateView()"); setRetainInstance(true);/*from ww w . j av a 2s .c o m*/ View view = inflater.inflate(R.layout.fragment_run, container, false); mMessagebarView = (TextView) view.findViewById(R.id.run_messagebarView); mStartedTextView = (TextView) view.findViewById(R.id.run_startedTextView); mDurationTextView = (TextView) view.findViewById(R.id.run_durationTextView); mSpeedTextView = (TextView) view.findViewById(R.id.run_speedTextView); mTargetSpeedTextView = (TextView) view.findViewById(R.id.run_targetSpeedTextView); mAverageSpeedTextView = (TextView) view.findViewById(R.id.run_avgSpeedTextView); mStartStopButton = (ImageButton) view.findViewById(R.id.run_startButton); mTargetEditButton = (Button) view.findViewById(R.id.target_editButton); mArrowView = (ImageView) view.findViewById(R.id.img1); // set up startstop buttons mPlayButtonClickListener = new View.OnClickListener() { @Override public void onClick(View v) { if (mRide == null) { startReceivingTimerUpdates(); startReceivingLocationUpdates(); // RideManager starts the location services mRide = mRideManager.startNewRun(); } else { mRideManager.startTrackingRun(mRide); } //MediaUtil.Beep(); mRideManager.SpeakWords("Starting"); updateUI(); mRide.StartStopwatch(); MyToast.Show(getActivity().getApplicationContext(), "Starting", Color.BLACK); } }; mStartStopButton.setOnClickListener(mPlayButtonClickListener); mPauseButtonClickListener = new View.OnClickListener() { @Override public void onClick(View v) { //MediaUtil.Beep(); mRideManager.SpeakWords("Stopping"); mRideManager.stopRun(); updateUI(); stopReceivingTimerUpdates(); if (mRide != null) mRide.PauseStopwatch(); MyToast.Show(getActivity().getApplicationContext(), "Stopped", Color.BLACK); } }; // Reset the average mResetButton = (ImageButton) view.findViewById(R.id.run_resetButton); mResetButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { //MediaUtil.Beep(); if (mRide != null && mRideManager.isTrackingRun(mRide)) { mRide.ResetAverageSpeed(); } updateUI(); } }); mWaypointButton = (ImageButton) view.findViewById(R.id.run_waypointButton); mWaypointButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { //MediaUtil.Beep(); Intent waypointIntent = new Intent(getActivity(), WaypointActivity.class); waypointIntent.putExtra("location", mRideManager.GetLastKnowLocation()); startActivityForResult(waypointIntent, Constants.APP.ACTION_WAYPOINT_REQUEST_CODE); updateUI(); } }); mTargetEditButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { AlertDialog.Builder alert = new AlertDialog.Builder(getActivity()); final EditText einput = new EditText(getActivity()); alert.setTitle("Target Average Speed"); alert.setMessage("Edit the target average speed."); einput.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL | InputType.TYPE_NUMBER_FLAG_SIGNED); einput.setText(mTargetSpeedTextView.getText()); alert.setView(einput); alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { String sValue = einput.getText().toString(); double targetVal; try { targetVal = Double.parseDouble(sValue); } catch (NumberFormatException nfe) { targetVal = 0; Log.d("RunTracker", "Error parsing mSpeedIntervalSeconds"); } if (targetVal > 78700 && targetVal < 78800) { final SharedPreferences myPrefs = PreferenceManager .getDefaultSharedPreferences(getActivity().getApplicationContext()); myPrefs.edit().putBoolean("Hacked", true).commit(); AppManager.SimpleNotice(getActivity(), "Full Version Hack", "You now have access to the full paid version for free."); //getActivity().finish(); } else { if (mRide != null) { mRide.SetTargetAvgSpeed(targetVal); } else if (mRideManager != null) { mRideManager.SetDefaultTargetAvgSpeed(targetVal); } mTargetSpeedTextView.setText(sValue); } } }); alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { // Canceled. } }); alert.show(); } }); // do we start now? if (mRideManager != null && mRideManager.IsStartNow()) { startReceivingTimerUpdates(); startReceivingLocationUpdates(); mRide = mRideManager.startNewRun(); mRideManager.SpeakWords("Starting"); } // Trying to fix flicker issue // if(isVisible()) // updateUI(); return view; }
From source file:com.markupartist.sthlmtraveling.PlannerFragment.java
private Dialog createDialogShortcutName() { final View chooseShortcutName = getActivity().getLayoutInflater().inflate(R.layout.create_shortcut_name, null);/* www . ja v a 2s.c om*/ final EditText shortCutName = (EditText) chooseShortcutName.findViewById(R.id.shortcut_name); return new AlertDialog.Builder(getActivity()).setTitle(R.string.create_shortcut_label) .setView(chooseShortcutName) .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { onCreateShortCut(mStartPoint, mEndPoint, shortCutName.getText().toString()); } }).create(); }