List of usage examples for android.widget EditText EditText
public EditText(Context context)
From source file:net.pocketmagic.android.carousel.MainActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //no keyboard unless requested by user getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); // compute screen size and scaling Singleton.getInstance().InitGUIFrame(this); int padding = m_Inst.Scale(10); // create the interface : full screen container RelativeLayout panel = new RelativeLayout(this); panel.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); panel.setPadding(padding, padding, padding, padding); panel.setBackgroundDrawable(new GradientDrawable(GradientDrawable.Orientation.TOP_BOTTOM, new int[] { Color.WHITE, Color.GRAY })); setContentView(panel);/*from w ww. jav a 2 s . com*/ // copy images from assets to sdcard AppUtils.AssetFileCopy(this, "/mnt/sdcard/plasma1.png", "plasma1.png", false); AppUtils.AssetFileCopy(this, "/mnt/sdcard/plasma2.png", "plasma2.png", false); AppUtils.AssetFileCopy(this, "/mnt/sdcard/plasma3.png", "plasma3.png", false); AppUtils.AssetFileCopy(this, "/mnt/sdcard/plasma4.png", "plasma4.png", false); //Create carousel view documents ArrayList<CarouselDataItem> Docus = new ArrayList<CarouselDataItem>(); for (int i = 0; i < 1000; i++) { CarouselDataItem docu; if (i % 4 == 0) docu = new CarouselDataItem("/mnt/sdcard/plasma1.png", 0, "First Image " + i); else if (i % 4 == 1) docu = new CarouselDataItem("/mnt/sdcard/plasma2.png", 0, "Second Image " + i); else if (i % 4 == 2) docu = new CarouselDataItem("/mnt/sdcard/plasma3.png", 0, "Third Image " + i); else docu = new CarouselDataItem("/mnt/sdcard/plasma4.png", 0, "4th Image " + i); Docus.add(docu); } // add the serach filter EditText etSearch = new EditText(this); etSearch.setHint("Search your documents"); etSearch.setSingleLine(); etSearch.setTextColor(Color.BLACK); etSearch.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_menu_search, 0, 0, 0); AppUtils.AddView(panel, etSearch, LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, new int[][] { new int[] { RelativeLayout.CENTER_HORIZONTAL }, new int[] { RelativeLayout.ALIGN_PARENT_TOP } }, -1, -1); etSearch.addTextChangedListener((TextWatcher) this); // add logo TextView tv = new TextView(this); tv.setTextColor(Color.BLACK); tv.setText("www.pocketmagic.net"); AppUtils.AddView(panel, tv, LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, new int[][] { new int[] { RelativeLayout.CENTER_HORIZONTAL }, new int[] { RelativeLayout.ALIGN_PARENT_BOTTOM } }, -1, -1); // create the carousel CarouselView coverFlow = new CarouselView(this); // create adapter and specify device independent items size (scaling) // for more details see: http://www.pocketmagic.net/2013/04/how-to-scale-an-android-ui-on-multiple-screens/ m_carouselAdapter = new CarouselViewAdapter(this, Docus, m_Inst.Scale(400), m_Inst.Scale(300)); coverFlow.setAdapter(m_carouselAdapter); coverFlow.setSpacing(-1 * m_Inst.Scale(150)); coverFlow.setSelection(Integer.MAX_VALUE / 2, true); coverFlow.setAnimationDuration(1000); coverFlow.setOnItemSelectedListener((OnItemSelectedListener) this); AppUtils.AddView(panel, coverFlow, LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT, new int[][] { new int[] { RelativeLayout.CENTER_IN_PARENT } }, -1, -1); }
From source file:net.kjmaster.cookiemom.editor.EditDataActivity.java
private void populateTable(final List<CookieTransactions> cookieTransactionsList, Context mContext) { edit_data_table.setShrinkAllColumns(true); for (final CookieTransactions cookieTransactions : cookieTransactionsList) { if ((cookieTransactions.getTransBoxes() != 0) || (cookieTransactions.getTransCash() != 0)) { TableRow tr = new TableRow(mContext); tr.setTag(cookieTransactions); TextView textView = new TextView(mContext); textView.setText(java.text.DateFormat.getInstance().format(cookieTransactions.getTransDate())); textView.setEnabled(false);//from w w w . ja v a2 s .c om tr.addView(textView); TextView textView2 = new TextView(mContext); try { if (cookieTransactions.getTransScoutId() < 0) { if (cookieTransactions.getTransBoothId() > 0) { textView2.setText(cookieTransactions.getBooth().getBoothLocation()); } else { textView2.setText("Cupboard"); } } else { textView2.setText(cookieTransactions.getScout().getScoutName()); } } catch (Exception e) { textView2.setText(""); } textView2.setEnabled(false); tr.addView(textView2); TextView textView1 = new TextView(mContext); textView1.setText(cookieTransactions.getCookieType()); textView1.setEnabled(false); tr.addView(textView1); EditText textView3 = new EditText(mContext); textView3.setText(cookieTransactions.getTransBoxes().toString()); textView3.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) { if (mActionMode == null) { startActionMode(actionCall); } } @Override public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) { } @Override public void afterTextChanged(Editable editable) { try { cookieTransactions.setTransBoxes(Integer.valueOf(editable.toString())); cookieTransactionsList.add(cookieTransactions); //Main.daoSession.getCookieTransactionsDao().update(cookieTransactions); } catch (Exception ignored) { } } }); tr.addView(textView3); EditText textView4 = new EditText(mContext); textView4.setText( NumberFormat.getCurrencyInstance().format(cookieTransactions.getTransCash().floatValue())); textView4.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) { if (mActionMode == null) { startActionMode(actionCall); } } @Override public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) { } @Override public void afterTextChanged(Editable editable) { try { cookieTransactions.setTransCash(Double.valueOf(editable.toString())); cookieTransactionsList.add(cookieTransactions); } catch (Exception ignored) { } } }); tr.addView(textView4); edit_data_table.addView(tr); } } }
From source file:com.github.wakhub.monodict.activity.bean.ActivityHelper.java
public AlertDialog.Builder buildInputDialog(CharSequence text, DialogInterface.OnClickListener onClickListener) { final EditText editText = new EditText(activity); if (text != null) { editText.setText(text);/*from w w w . j a v a 2s . com*/ } editText.setId(android.R.id.text1); return new AlertDialog.Builder(activity).setView(editText) .setPositiveButton(android.R.string.ok, onClickListener) .setNegativeButton(android.R.string.cancel, null); }
From source file:com.inaetics.demonstrator.MainActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.action_settings_editProperties: final EditText edittext = new EditText(this); edittext.getBackground().setColorFilter(ContextCompat.getColor(this, R.color.android_green), PorterDuff.Mode.SRC_ATOP); String props = config.propertiesToString(); showInputDialog(edittext, "Edit Properties", props, new DialogInterface.OnClickListener() { @Override/*from w w w . jav a 2s. co m*/ public void onClick(DialogInterface dialogInterface, int i) { config.setProperties(edittext.getText().toString()); Toast.makeText(getBaseContext(), "properties changed", Toast.LENGTH_SHORT).show(); } }); return true; case R.id.action_startQR: new IntentIntegrator(this).setOrientationLocked(true).initiateScan(); return true; case R.id.action_download: AlertDialog.Builder builder = new AlertDialog.Builder(this, R.style.DialogTheme); final EditText text = new EditText(this); text.getBackground().setColorFilter(ContextCompat.getColor(this, R.color.android_green), PorterDuff.Mode.SRC_ATOP); builder.setView(text); builder.setPositiveButton("Download", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { download(text.getText().toString()); } }); builder.setNegativeButton("Cancel", null); builder.setTitle("Download bundle from URL"); AlertDialog realDialog = builder.create(); realDialog.getWindow().getAttributes().width = WindowManager.LayoutParams.MATCH_PARENT; realDialog.show(); return true; } return super.onOptionsItemSelected(item); }
From source file:org.deviceconnect.android.deviceplugin.hue.activity.fragment.HueFragment04.java
/** * Edit serial./*from ww w . j a va2 s . com*/ */ private void editSerial() { final EditText editText = new EditText(getActivity()); editText.setOnKeyListener(new View.OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { if (event.getAction() == KeyEvent.ACTION_DOWN && keyCode == KeyEvent.KEYCODE_ENTER) { InputMethodManager inputMethodManager = (InputMethodManager) getActivity() .getSystemService(Context.INPUT_METHOD_SERVICE); inputMethodManager.hideSoftInputFromWindow(v.getWindowToken(), 0); return true; } return false; } }); AlertDialog dialog = new AlertDialog.Builder(getActivity()).setTitle(R.string.frag04_serial_number_title) .setMessage(R.string.frag04_serial_number_message).setView(editText) .setPositiveButton(R.string.frag04_serial_ok, new DialogInterface.OnClickListener() { public void onClick(final DialogInterface dialog, final int whichButton) { String serial = editText.getText().toString(); searchLightManually(serial); } }).setNegativeButton(R.string.frag04_serial_cancel, new DialogInterface.OnClickListener() { public void onClick(final DialogInterface dialog, final int whichButton) { } }).show(); final Button positiveButton = dialog.getButton(AlertDialog.BUTTON_POSITIVE); positiveButton.setEnabled(false); // Input limit of the serial number InputFilter inputFilter = new InputFilter() { @Override public CharSequence filter(final CharSequence source, final int start, final int end, final Spanned dest, final int dstart, final int dend) { if (source.toString().matches("[0-9a-fA-F]+")) { return source; } else { return ""; } } }; InputFilter[] filters = new InputFilter[] { inputFilter, new InputFilter.LengthFilter(6) }; editText.setFilters(filters); editText.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(final CharSequence s, final int start, final int count, final int after) { } @Override public void onTextChanged(final CharSequence s, final int start, final int before, final int count) { positiveButton.setEnabled(editText.length() == 6); } @Override public void afterTextChanged(final Editable s) { } }); editText.setHint(R.string.frag04_serial_number_hint); }
From source file:com.xalops.spotifystreamer.fragments.SearchListFragment.java
/** * Provide default implementation to return a simple list view. Subclasses * can override to replace with their own layout. If doing so, the * returned view hierarchy <em>must</em> have a ListView whose id * is {@link android.R.id#list android.R.id.list} and can optionally * have a sibling view id {@link android.R.id#empty android.R.id.empty} * that is to be shown when the list is empty. * * <p>If you are overriding this method with your own custom content, * consider including the standard layout {@link android.R.layout#list_content} * in your layout file, so that you continue to retain all of the standard * behavior of ListFragment. In particular, this is currently the only * way to have the built-in indeterminant progress state be shown. *///w w w.j av a 2s . c om @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final Context context = getActivity(); FrameLayout root = new FrameLayout(context); //QUICK Inflate from XML file //inflater.inflate(R.layout.search_list_detail, root); // ------------------------------------------------------------------ LinearLayout pframe = new LinearLayout(context); pframe.setId(INTERNAL_PROGRESS_CONTAINER_ID); pframe.setOrientation(LinearLayout.VERTICAL); pframe.setVisibility(View.GONE); pframe.setGravity(Gravity.CENTER); ProgressBar progress = new ProgressBar(context, null, android.R.attr.progressBarStyleLarge); pframe.addView(progress, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); root.addView(pframe, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); // ------------------------------------------------------------------ RelativeLayout rlayout = new RelativeLayout(context); EditText et = new EditText(getActivity()); et.setId(INTERNAL_SEARCH_FIELD_ID); et.setSingleLine(true); et.setInputType(InputType.TYPE_CLASS_TEXT); et.setImeOptions(EditorInfo.IME_ACTION_DONE); RelativeLayout.LayoutParams etRLayoutParams = new RelativeLayout.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); etRLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT); etRLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_TOP); FrameLayout lframe = new FrameLayout(context); lframe.setId(INTERNAL_LIST_CONTAINER_ID); RelativeLayout.LayoutParams lframeRLayoutParams = new RelativeLayout.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); lframeRLayoutParams.addRule(RelativeLayout.BELOW, INTERNAL_SEARCH_FIELD_ID); TextView tv = new TextView(getActivity()); tv.setId(INTERNAL_EMPTY_ID); tv.setGravity(Gravity.CENTER); lframe.addView(tv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); ListView lv = new ListView(getActivity()); lv.setId(android.R.id.list); lv.setDrawSelectorOnTop(false); lframe.addView(lv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); rlayout.addView(et, etRLayoutParams); rlayout.addView(lframe, lframeRLayoutParams); root.addView(rlayout, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); // ------------------------------------------------------------------ root.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); return root; }
From source file:com.francetelecom.rd.app.nodessimulator.NodeListActivity.java
private void createIdAlert() { AlertDialog.Builder alert = new AlertDialog.Builder(this); alert.setTitle("Please, enter your device ID (1 < id < 127)"); // Set an EditText view to get user input final EditText input = new EditText(this); input.setInputType(InputType.TYPE_CLASS_NUMBER); alert.setView(input);/*from w w w.jav a2 s .c om*/ alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { int id = Integer.parseInt(input.getText().toString()); if (id > 0 && id < 128) { DeviceManager.getInstance().setDeviceId(id); start(); } else { Context context = getApplicationContext(); CharSequence error = "Please enter an id between 1 and 127"; int duration = Toast.LENGTH_LONG; Toast toast = Toast.makeText(context, error, duration); toast.show(); createIdAlert(); } } }); alert.show(); }
From source file:com.launcher.silverfish.launcher.appdrawer.TabbedAppDrawerFragment.java
private void promptNewTab() { AlertDialog.Builder builder = new AlertDialog.Builder(getContext()); // Set up the dialog builder.setTitle(getString(R.string.text_new_tab_name)); // Set up the input final EditText input = new EditText(getContext()); // Specify the type of input expected input.setInputType(InputType.TYPE_CLASS_TEXT); builder.setView(input);/*from w ww. j a v a 2 s.c o m*/ // setup the buttons builder.setPositiveButton(getString(R.string.text_add_tab), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { try { tabHandler.addTab(input.getText().toString()); } catch (IllegalArgumentException e) { // This means that the tab name was empty. showToast(R.string.text_cannot_name_empty); } } }); builder.setNegativeButton(getString(R.string.text_cancel), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { dialogInterface.cancel(); } }); builder.show(); }
From source file:org.liberty.android.fantastischmemopro.downloader.DownloaderFE.java
@Override protected void initialRetrieve() { mHandler = new Handler(); dlAdapter = new DownloadListAdapter(this, R.layout.filebrowser_item); listView = (ListView) findViewById(R.id.file_list); listView.setAdapter(dlAdapter);/*from w ww.j a v a 2 s .co m*/ final SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(this); final SharedPreferences.Editor editor = settings.edit(); String prevInput = settings.getString("prev_fe_input", ""); final EditText input = new EditText(this); input.setText(prevInput); new AlertDialog.Builder(this).setTitle(getString(R.string.fe_search_title)) .setMessage(getString(R.string.fe_search_message)).setView(input) .setPositiveButton(getString(R.string.ok_text), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { final String value = input.getText().toString(); editor.putString("prev_fe_input", value); editor.commit(); mProgressDialog = ProgressDialog.show(DownloaderFE.this, getString(R.string.loading_please_wait), getString(R.string.loading_connect_net), true, true, new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { finish(); } }); new Thread() { public void run() { try { final List<DownloadItem> dil = retrieveList(value); mHandler.post(new Runnable() { public void run() { dlAdapter.addList(dil); mProgressDialog.dismiss(); } }); } catch (final Exception e) { mHandler.post(new Runnable() { public void run() { mProgressDialog.dismiss(); new AlertDialog.Builder(DownloaderFE.this) .setTitle(R.string.downloader_connection_error) .setMessage( getString(R.string.downloader_connection_error_message) + e.toString()) .setPositiveButton(getString(R.string.ok_text), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { finish(); } }) .create().show(); } }); } } }.start(); } }).setNegativeButton(getString(R.string.cancel_text), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { finish(); } }).setOnCancelListener(new DialogInterface.OnCancelListener() { public void onCancel(DialogInterface dialog) { finish(); } }).create().show(); }
From source file:com.piusvelte.mosaic.android.MosaicMap.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.map, container, false); btnNickname = ((Button) rootView.findViewById(R.id.nickname)); btnNickname.setOnClickListener(new View.OnClickListener() { @Override//from ww w . j ava 2 s. c o m public void onClick(View v) { Activity activity = getActivity(); final EditText newNickname = new EditText(activity); newNickname.setText(btnNickname.getText().toString()); new AlertDialog.Builder(activity).setTitle("Change nickname").setView(newNickname) .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { String nickname = newNickname.getText().toString(); if (nickname.length() > 0) { if (!nickname.equals(btnNickname.getText().toString())) { try { iLocationService.changeNickname(nickname); } catch (RemoteException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } else { //TODO no name } } }).setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }).show(); } }); return rootView; }