List of usage examples for android.widget EditText getText
@Override
public Editable getText()
From source file:com.vkassin.mtrade.Common.java
public static void putArcDeal(final Context ctx) { final Dialog dialog = new Dialog(ctx); dialog.setContentView(R.layout.arcdeal_dialog); dialog.setTitle(R.string.ArcDealDialogTitle); datetxt = (EditText) dialog.findViewById(R.id.expdateedit); SimpleDateFormat sdf = new SimpleDateFormat("dd.MM.yyyy"); Date dat1 = new Date(); datetxt.setText(sdf.format(dat1));//from w w w. ja v a 2 s. com mYear = dat1.getYear() + 1900; mMonth = dat1.getMonth(); mDay = dat1.getDate(); final Date dat = new GregorianCalendar(mYear, mMonth, mDay).getTime(); datetxt.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { Log.i(TAG, "Show DatePickerDialog"); DatePickerDialog dpd = new DatePickerDialog(ctx, mDateSetListener, mYear, mMonth, mDay); dpd.show(); } }); TextView itext = (TextView) dialog.findViewById(R.id.instrtext); itext.setText(Common.arcfilter); Button customDialog_Cancel = (Button) dialog.findViewById(R.id.cancelbutt); customDialog_Cancel.setOnClickListener(new Button.OnClickListener() { public void onClick(View arg0) { dialog.dismiss(); } }); Button customDialog_Put = (Button) dialog.findViewById(R.id.putorder); customDialog_Put.setOnClickListener(new Button.OnClickListener() { public void onClick(View arg0) { Double price = new Double(0); Long qval = new Long(0); final EditText pricetxt = (EditText) dialog.findViewById(R.id.priceedit); final EditText quanttxt = (EditText) dialog.findViewById(R.id.quantedit); try { price = Double.valueOf(pricetxt.getText().toString()); } catch (Exception e) { Toast.makeText(ctx, R.string.CorrectPrice, Toast.LENGTH_SHORT).show(); return; } try { qval = Long.valueOf(quanttxt.getText().toString()); } catch (Exception e) { Toast.makeText(ctx, R.string.CorrectQty, Toast.LENGTH_SHORT).show(); return; } // if (dat.compareTo(new GregorianCalendar(mYear, mMonth, mDay) // .getTime()) > 0) { // // Toast.makeText(ctx, R.string.CorrectDate, // Toast.LENGTH_SHORT).show(); // // return; // } long maxkey = 0; Iterator<String> itr2 = arcdealMap.keySet().iterator(); while (itr2.hasNext()) { String key1 = itr2.next(); long k = Long.parseLong(key1); if (k > maxkey) maxkey = k; } Deal adeal = new Deal(); Iterator<String> itr1 = instrMap.keySet().iterator(); while (itr1.hasNext()) { String key1 = itr1.next(); Instrument in = instrMap.get(key1); if (in.symbol.equals(Common.arcfilter)) { adeal.instrId = Long.valueOf(in.id); break; } } final RadioButton bu0 = (RadioButton) dialog.findViewById(R.id.radio0); adeal.price = price; adeal.qty = qval; adeal.dtime = new GregorianCalendar(mYear, mMonth, mDay).getTimeInMillis(); adeal.direct = bu0.isChecked() ? Long.valueOf(0) : Long.valueOf(1); Collection<String> lacc = Common.getAccountList(); adeal.account = (lacc == null) ? "" : lacc.iterator().next(); arcdealMap.put(String.valueOf(maxkey + 1), adeal); Common.saveArcDeals(); Common.arcActivity.refresh(); dialog.dismiss(); } }); dialog.show(); WindowManager.LayoutParams lp = new WindowManager.LayoutParams(); lp.copyFrom(dialog.getWindow().getAttributes()); lp.width = WindowManager.LayoutParams.FILL_PARENT; lp.height = WindowManager.LayoutParams.FILL_PARENT; dialog.getWindow().setAttributes(lp); }
From source file:com.notifry.android.SourceList.java
/** * Helper function to show a dialog to ask for a source name. *//*from w ww . j ava2 s .co m*/ private void askForSourceName() { final EditText input = new EditText(this); new AlertDialog.Builder(this).setTitle(getString(R.string.create_source)) .setMessage(getString(R.string.create_source_message)).setView(input) .setPositiveButton(getString(R.string.create), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int whichButton) { Editable value = input.getText(); if (value.length() > 0) { // Fire it off to the create source // function. createSource(value.toString()); } } }).setNegativeButton(getString(R.string.cancel), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int whichButton) { // No need to take any action. } }).show(); }
From source file:com.yschi.castscreen.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); if (savedInstanceState != null) { mResultCode = savedInstanceState.getInt(STATE_RESULT_CODE); mResultData = savedInstanceState.getParcelable(STATE_RESULT_DATA); }// w w w . ja v a2 s.com mContext = this; mMediaProjectionManager = (MediaProjectionManager) getSystemService(Context.MEDIA_PROJECTION_SERVICE); mDiscoverdMap = new HashMap<>(); mDiscoverListView = (ListView) findViewById(R.id.discover_listview); mDiscoverAdapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1); mDiscoverAdapter.addAll(mDiscoverdMap.keySet()); mDiscoverListView.setAdapter(mDiscoverAdapter); mDiscoverListView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { String name = mDiscoverAdapter.getItem(i); String ip = mDiscoverdMap.get(name); Log.d(TAG, "Select receiver name: " + name + ", ip: " + ip); mReceiverIp = ip; updateReceiverStatus(); mContext.getSharedPreferences(PREF_COMMON, 0).edit().putString(PREF_KEY_RECEIVER, mReceiverIp) .commit(); } }); // add server mode option mDiscoverAdapter.add(mContext.getString(R.string.server_mode)); mDiscoverdMap.put(mContext.getString(R.string.server_mode), ""); mReceiverTextView = (TextView) findViewById(R.id.receiver_textview); final EditText ipEditText = (EditText) findViewById(R.id.ip_edittext); final Button selectButton = (Button) findViewById(R.id.select_button); selectButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (ipEditText.getText().length() > 0) { mReceiverIp = ipEditText.getText().toString(); Log.d(TAG, "Using ip: " + mReceiverIp); updateReceiverStatus(); mContext.getSharedPreferences(PREF_COMMON, 0).edit() .putString(PREF_KEY_INPUT_RECEIVER, mReceiverIp).commit(); mContext.getSharedPreferences(PREF_COMMON, 0).edit().putString(PREF_KEY_RECEIVER, mReceiverIp) .commit(); } } }); ipEditText.setText(mContext.getSharedPreferences(PREF_COMMON, 0).getString(PREF_KEY_INPUT_RECEIVER, "")); Spinner formatSpinner = (Spinner) findViewById(R.id.format_spinner); ArrayAdapter<CharSequence> formatAdapter = ArrayAdapter.createFromResource(this, R.array.format_options, android.R.layout.simple_spinner_item); formatAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); formatSpinner.setAdapter(formatAdapter); formatSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) { mSelectedFormat = FORMAT_OPTIONS[i]; mContext.getSharedPreferences(PREF_COMMON, 0).edit().putInt(PREF_KEY_FORMAT, i).commit(); } @Override public void onNothingSelected(AdapterView<?> adapterView) { mSelectedFormat = FORMAT_OPTIONS[0]; mContext.getSharedPreferences(PREF_COMMON, 0).edit().putInt(PREF_KEY_FORMAT, 0).commit(); } }); formatSpinner.setSelection(mContext.getSharedPreferences(PREF_COMMON, 0).getInt(PREF_KEY_FORMAT, 0)); Spinner resolutionSpinner = (Spinner) findViewById(R.id.resolution_spinner); ArrayAdapter<CharSequence> resolutionAdapter = ArrayAdapter.createFromResource(this, R.array.resolution_options, android.R.layout.simple_spinner_item); resolutionAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); resolutionSpinner.setAdapter(resolutionAdapter); resolutionSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) { mSelectedWidth = RESOLUTION_OPTIONS[i][0]; mSelectedHeight = RESOLUTION_OPTIONS[i][1]; mSelectedDpi = RESOLUTION_OPTIONS[i][2]; mContext.getSharedPreferences(PREF_COMMON, 0).edit().putInt(PREF_KEY_RESOLUTION, i).commit(); } @Override public void onNothingSelected(AdapterView<?> adapterView) { mSelectedWidth = RESOLUTION_OPTIONS[0][0]; mSelectedHeight = RESOLUTION_OPTIONS[0][1]; mSelectedDpi = RESOLUTION_OPTIONS[0][2]; mContext.getSharedPreferences(PREF_COMMON, 0).edit().putInt(PREF_KEY_RESOLUTION, 0).commit(); } }); resolutionSpinner .setSelection(mContext.getSharedPreferences(PREF_COMMON, 0).getInt(PREF_KEY_RESOLUTION, 0)); Spinner bitrateSpinner = (Spinner) findViewById(R.id.bitrate_spinner); ArrayAdapter<CharSequence> bitrateAdapter = ArrayAdapter.createFromResource(this, R.array.bitrate_options, android.R.layout.simple_spinner_item); bitrateAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); bitrateSpinner.setAdapter(bitrateAdapter); bitrateSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) { mSelectedBitrate = BITRATE_OPTIONS[i]; mContext.getSharedPreferences(PREF_COMMON, 0).edit().putInt(PREF_KEY_BITRATE, i).commit(); } @Override public void onNothingSelected(AdapterView<?> adapterView) { mSelectedBitrate = BITRATE_OPTIONS[0]; mContext.getSharedPreferences(PREF_COMMON, 0).edit().putInt(PREF_KEY_BITRATE, 0).commit(); } }); bitrateSpinner.setSelection(mContext.getSharedPreferences(PREF_COMMON, 0).getInt(PREF_KEY_BITRATE, 0)); mReceiverIp = mContext.getSharedPreferences(PREF_COMMON, 0).getString(PREF_KEY_RECEIVER, ""); updateReceiverStatus(); startService(); }
From source file:com.cricketkorner.cricket.VitamioListActivity.java
private void ListFunction() { listView = (ListView) findViewById(R.id.listView); //copying array for (int i = 0; i < Singleton.getInstance().getChannelList().size(); i++) { title.add(Singleton.getInstance().getChannelList().get(i).getChannelName()); desc.add("Long Press This Channel To Report, Id: " + Singleton.getInstance().getChannelList().get(i).getChannelId()); thumb.add(R.drawable.ic_launcher); }//from ww w . ja v a 2 s. c om listView.setAdapter(new VersionAdapter(VitamioListActivity.this)); listView.setOnItemLongClickListener(new OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> parent, View view, final int position, long id) { AlertDialog.Builder alert = new AlertDialog.Builder(VitamioListActivity.this); alert.setTitle("Report Broken Link"); alert.setMessage("Message: (Channel not working?)"); // Set an EditText view to get user input final EditText input = new EditText(VitamioListActivity.this); alert.setView(input); alert.setPositiveButton("Submit", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int whichButton) { String value = input.getText().toString(); if (isNetworkAvailable()) { new ReportFeedback().execute("http://yoururl.com/LiveStreaming/reportFeedback.php", value, Singleton.getInstance().getChannelList().get(position).getChannelId()); } } }); alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int whichButton) { // Canceled. } }); alert.show(); return false; } }); listView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) { int pos = arg2; LayoutInflater layoutInflator = getLayoutInflater(); View layout = layoutInflator.inflate(R.layout.custom_toast, (ViewGroup) findViewById(R.id.toast_layout_root)); ImageView iv = (ImageView) layout.findViewById(R.id.toast_iv); TextView tv = (TextView) layout.findViewById(R.id.toast_tv); iv.setBackgroundResource(thumb.get(pos)); tv.setText(title.get(pos)); Intent intent = new Intent(VitamioListActivity.this, VideoViewDemo.class); intent.putExtra("path", Singleton.getInstance().getChannelList().get(pos).getChannelPath()); startAppAd.onBackPressed(); startActivity(intent); } }); }
From source file:com.google.sample.devicelab.MainActivity.java
@Override public void onDialogPositiveClick(DialogFragment dialog) { // User touched the dialog's positive button EditText idET = (EditText) dialog.getDialog().findViewById(R.id.idET); EditText numberET = (EditText) dialog.getDialog().findViewById(R.id.numberET); UserSettings.setAppEngineId(this, idET.getText().toString().trim()); UserSettings.setAppEngineNumber(this, numberET.getText().toString().trim()); if (!UserSettings.getAppEngineNumber(this).equals("")) { registerWithPush();//from w w w . ja v a 2 s.co m } if (!UserSettings.getAppEngineId(this).equals("")) { new GAEIdVerifier(this).execute(); } refreshUI(); }
From source file:com.entertailion.android.launcher.Dialogs.java
/** * Change the name of the current row//w w w. ja v a 2s .c o m * * @param context */ public static void displayChangeRowName(final Launcher context) { // Set an EditText view to get user input final EditText input = new EditText(context); new AlertDialog.Builder(context).setTitle(context.getString(R.string.dialog_row_name_title)) .setMessage(context.getString(R.string.dialog_row_name)).setView(input) .setPositiveButton(context.getString(R.string.dialog_ok), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { Editable value = input.getText(); context.changeCurrentRowName(value.toString()); } }).setNegativeButton(context.getString(R.string.dialog_cancel), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { // Do nothing. } }) .show(); }
From source file:com.andrewshu.android.reddit.submit.SubmitLinkActivity.java
private boolean validateTextForm() { final EditText titleText = (EditText) findViewById(R.id.submit_text_title); final EditText redditText = (EditText) findViewById(R.id.submit_text_reddit); if (StringUtils.isEmpty(titleText.getText())) { Common.showErrorToast("Please provide a title.", Toast.LENGTH_LONG, this); return false; }//from www . jav a 2 s. co m if (StringUtils.isEmpty(redditText.getText())) { Common.showErrorToast("Please provide a subreddit.", Toast.LENGTH_LONG, this); return false; } return true; }
From source file:com.feedhenry.sync.activities.ListOfItemsActivity.java
private void showPopup(final ShoppingItem item) { final View customView = View.inflate(getApplicationContext(), R.layout.form_item_dialog, null); final EditText name = (EditText) customView.findViewById(R.id.name); name.setText(item.getName());//from w w w .j a va 2 s.c o m new MaterialDialog.Builder(this) .title((item.getId() == null) ? getString(R.string.new_item) : getString(R.string.edit_item) + ": " + item.getName()) .customView(customView, false).positiveText(R.string.save) .onPositive(new MaterialDialog.SingleButtonCallback() { @Override public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) { item.setName(name.getText().toString()); saveItem(item); } }).negativeText(R.string.cancel).show(); }
From source file:at.bitfire.davdroid.ui.setup.AccountDetailsFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final View v = inflater.inflate(R.layout.login_account_details, container, false); Button btnBack = (Button) v.findViewById(R.id.back); btnBack.setOnClickListener(new View.OnClickListener() { @Override/*from www . ja v a2 s . c o m*/ public void onClick(View v) { getFragmentManager().popBackStack(); } }); DavResourceFinder.Configuration config = (DavResourceFinder.Configuration) getArguments() .getSerializable(KEY_CONFIG); final EditText editName = (EditText) v.findViewById(R.id.account_name); editName.setText( (config.calDAV != null && config.calDAV.email != null) ? config.calDAV.email : config.userName); // CardDAV-specific v.findViewById(R.id.carddav).setVisibility(config.cardDAV != null ? View.VISIBLE : View.GONE); spnrGroupMethod = (Spinner) v.findViewById(R.id.contact_group_method); Button btnCreate = (Button) v.findViewById(R.id.create_account); btnCreate.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { String name = editName.getText().toString(); if (name.isEmpty()) editName.setError(getString(R.string.login_account_name_required)); else { if (createAccount(name, (DavResourceFinder.Configuration) getArguments().getSerializable(KEY_CONFIG))) { getActivity().setResult(Activity.RESULT_OK); getActivity().finish(); } else Snackbar.make(v, R.string.login_account_not_created, Snackbar.LENGTH_LONG).show(); } } }); return v; }