List of usage examples for android.widget EditText EditText
public EditText(Context context)
From source file:com.tinbytes.simplelistviewapp.SimpleListViewActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { int id = item.getItemId(); switch (id) { case R.id.action_add_animal: final EditText input = new EditText(this); input.setInputType(InputType.TYPE_CLASS_TEXT); new AlertDialog.Builder(this).setTitle("New Animal").setView(input) .setPositiveButton("OK", new DialogInterface.OnClickListener() { @Override/*from w w w .j ava 2s. c om*/ public void onClick(DialogInterface dialog, int which) { ContentValues cv = new ContentValues(); cv.put(DatabaseContract.AnimalColumns.NAME, input.getText().toString()); cv.put(DatabaseContract.AnimalColumns.CATEGORY, "Unknown"); Uri uri = getContentResolver().insert(DatabaseContract.AnimalTable.CONTENT_URI, cv); if (uri != null) { getContentResolver().notifyChange(uri, null); } } }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }).show(); return true; } return super.onOptionsItemSelected(item); }
From source file:com.softminds.matrixcalculator.base_fragments.EditFragment.java
@Override public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View V = inflater.inflate(R.layout.fragment_edit, container, false); CardView cardView = V.findViewById(R.id.EditMatrixCard); SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getContext()); String string = sharedPreferences.getString("ELEVATE_AMOUNT", "4"); String string2 = sharedPreferences.getString("CARD_CHANGE_KEY", "#bdbdbd"); cardView.setCardElevation(Integer.parseInt(string)); CardView.LayoutParams params1 = new CardView.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); //noinspection ConstantConditions int index = getArguments().getInt("INDEX"); //noinspection ConstantConditions MatrixV2 m = ((GlobalValues) getActivity().getApplication()).GetCompleteList().get(index); GridLayout gridLayout = new GridLayout(getContext()); gridLayout.setRowCount(m.getNumberOfRows()); gridLayout.setColumnCount(m.getNumberOfCols()); for (int i = 0; i < m.getNumberOfRows(); i++) { for (int j = 0; j < m.getNumberOfCols(); j++) { EditText editText = new EditText(getContext()); editText.setId(i * 10 + j);// w w w. j a va 2 s . c o m editText.setBackgroundColor(Color.parseColor(string2)); editText.setGravity(Gravity.CENTER); if (!PreferenceManager.getDefaultSharedPreferences(getContext()).getBoolean("DECIMAL_USE", true)) { editText.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_SIGNED); } else { editText.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL | InputType.TYPE_NUMBER_FLAG_SIGNED); } editText.setFilters(new InputFilter[] { new InputFilter.LengthFilter(getLength()) }); if (!PreferenceManager.getDefaultSharedPreferences(getContext()).getBoolean("SMART_FIT_KEY", false)) { editText.setWidth(ConvertTopx(62)); editText.setTextSize(SizeReturner(3, 3, PreferenceManager .getDefaultSharedPreferences(getContext()).getBoolean("EXTRA_SMALL_FONT", false))); } else { editText.setWidth(ConvertTopx(CalculatedWidth(m.getNumberOfCols()))); editText.setTextSize(SizeReturner(m.getNumberOfRows(), m.getNumberOfCols(), PreferenceManager .getDefaultSharedPreferences(getContext()).getBoolean("EXTRA_SMALL_FONT", false))); } editText.setText(SafeSubString(GetText(m.getElementOf(i, j)), getLength())); editText.setSingleLine(); GridLayout.Spec Row = GridLayout.spec(i, 1); GridLayout.Spec Col = GridLayout.spec(j, 1); GridLayout.LayoutParams params = new GridLayout.LayoutParams(Row, Col); params.leftMargin = params.topMargin = params.bottomMargin = params.rightMargin = getResources() .getDimensionPixelOffset(R.dimen.border_width); gridLayout.addView(editText, params); } } gridLayout.setLayoutParams(params1); cardView.addView(gridLayout); RootView = V; return V; }
From source file:com.seedform.dfatester.viewer.AlphabetListFragment.java
private void openAddSymbolDialog() { final EditText input = new EditText(getActivity()); input.setHint(R.string.hint_symbol_entry); input.setGravity(Gravity.CENTER);/*from w w w.jav a 2 s. c o m*/ input.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS); new AlertDialog.Builder(getActivity()).setTitle(R.string.title_symbol_entry).setView(input) .setPositiveButton(R.string.action_add_symbol, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { String inputText = input.getText().toString(); if (inputText.length() != 0) { for (char c : inputText.toCharArray()) { mDFA.addSymbol(c); } mAdapter.notifyDataSetChanged(); Tool.createToast(getActivity(), R.string.msg_symbols_added, Toast.LENGTH_SHORT); } } }).show(); }
From source file:de.vanita5.twittnuker.fragment.support.SetUserNicknameDialogFragment.java
@Override public Dialog onCreateDialog(final Bundle savedInstanceState) { final Bundle args = getArguments(); final String nick = args.getString(EXTRA_NAME); final Context wrapped = ThemeUtils.getDialogThemedContext(getActivity()); final AlertDialog.Builder builder = new AlertDialog.Builder(wrapped); builder.setTitle(R.string.set_nickname); builder.setPositiveButton(android.R.string.ok, this); if (!TextUtils.isEmpty(nick)) { builder.setNeutralButton(R.string.clear, this); }/*from w w w . j av a 2s . com*/ builder.setNegativeButton(android.R.string.cancel, null); final FrameLayout view = new FrameLayout(wrapped); mEditText = new EditText(wrapped); final FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT); lp.leftMargin = lp.topMargin = lp.bottomMargin = lp.rightMargin = getResources() .getDimensionPixelSize(R.dimen.element_spacing_normal); view.addView(mEditText, lp); builder.setView(view); mEditText.setText(nick); return builder.create(); }
From source file:de.nico.ha_manager.activities.Preferences.java
@SuppressWarnings("deprecation") private void checkPreferences() { Preference language = findPreference("pref_app_language"); language.setOnPreferenceClickListener(new OnPreferenceClickListener() { @Override/*from w w w . jav a 2s . c om*/ public boolean onPreferenceClick(Preference preference) { Utils.langSpinner(c); return true; } }); Preference subjects_add = findPreference("subjects_add"); subjects_add.setOnPreferenceClickListener(new OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { final EditText input = new EditText(c); input.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_SENTENCES); AlertDialog.Builder alertDialog = new AlertDialog.Builder(c); alertDialog.setTitle(getString(R.string.dialog_addSubject)) .setMessage(getString(R.string.dialog_addSubject_message)).setView(input) .setPositiveButton(getString(android.R.string.ok), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface d, int i) { Subject.add(c, input.getText().toString()); } }).setNegativeButton((getString(android.R.string.no)), null).show(); return true; } }); Preference subjects_reset = findPreference("subjects_reset"); subjects_reset.setOnPreferenceClickListener(new OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { AlertDialog.Builder alertDialog = new AlertDialog.Builder(c); alertDialog.setTitle(getString(R.string.dialog_delete)) .setMessage(getString(R.string.dialog_really_delete_subs)) .setPositiveButton((getString(android.R.string.yes)), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface d, int i) { Subject.setDefault(c); } }) .setNegativeButton((getString(android.R.string.no)), null).show(); return true; } }); Preference feedback_share = findPreference("feedback_share"); feedback_share.setOnPreferenceClickListener(new OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { return Utils.shareApp(c); } }); Preference importexport_export = findPreference("pref_importexport_export"); importexport_export.setOnPreferenceClickListener(new OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { AlertDialog.Builder alertDialog = new AlertDialog.Builder(c); alertDialog.setTitle(getString(R.string.pref_homework_export)) .setMessage(getString(R.string.dialog_export_message)) .setPositiveButton((getString(android.R.string.yes)), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface d, int i) { Homework.exportIt(c); } }) .setNegativeButton((getString(android.R.string.no)), null).show(); return true; } }); Preference importexport_import = findPreference("pref_importexport_import"); importexport_import.setOnPreferenceClickListener(new OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { AlertDialog.Builder alertDialog = new AlertDialog.Builder(c); alertDialog.setTitle(getString(R.string.pref_homework_import)) .setMessage(getString(R.string.dialog_import_message)) .setPositiveButton((getString(android.R.string.yes)), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface d, int i) { Homework.importIt(c); } }) .setNegativeButton((getString(android.R.string.no)), null).show(); return true; } }); }
From source file:de.nico.asura.activities.WebView1.java
private void checkLogin() { // Layout for Dialog final LinearLayout layout = new LinearLayout(this); layout.setOrientation(LinearLayout.VERTICAL); final EditText edit_name = new EditText(this); edit_name.setHint(getString(R.string.menu_Web_1_auth_fiFi)); layout.addView(edit_name);//from w ww .j a v a2s. com final EditText edit_pass = new EditText(this); edit_pass.setHint(getString(R.string.menu_Web_1_auth_seFi)); edit_pass.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD); layout.addView(edit_pass); final Builder builder = new Builder(this); builder.setTitle(getString(R.string.menu_Web_1_name)).setCancelable(false).setView(layout) .setPositiveButton(getString(android.R.string.ok), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int whichButton) { firstField = edit_name.getText().toString(); secondField = edit_pass.getText().toString(); // Nothing? if (firstField.length() == 0 || secondField.length() == 0) { Utils.makeShortToast(WebView1.this, getString(R.string.wrong)); checkLogin(); return; } final Editor editor = prefs.edit(); editor.putString(sharedPrefFiFi, firstField); editor.putString(sharedPrefSeFi, secondField); editor.apply(); openWebView(); } }).setNegativeButton(getString(android.R.string.cancel), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int whichButton) { WebView1.this.finish(); } }).show(); }
From source file:de.nico.asura.activities.WebView2.java
private void checkLogin() { // Layout for Dialog final LinearLayout layout = new LinearLayout(this); layout.setOrientation(LinearLayout.VERTICAL); final EditText edit_name = new EditText(this); edit_name.setHint(getString(R.string.menu_Web_2_auth_fiFi)); layout.addView(edit_name);//from ww w . j a v a 2 s .c o m final EditText edit_pass = new EditText(this); edit_pass.setHint(getString(R.string.menu_Web_2_auth_seFi)); edit_pass.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD); layout.addView(edit_pass); final Builder builder = new Builder(this); builder.setTitle(getString(R.string.menu_Web_2_name)).setCancelable(false).setView(layout) .setPositiveButton(getString(android.R.string.ok), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int whichButton) { firstField = edit_name.getText().toString(); secondField = edit_pass.getText().toString(); // Nothing? if (firstField.length() == 0 || secondField.length() == 0) { Utils.makeShortToast(WebView2.this, getString(R.string.wrong)); checkLogin(); return; } final Editor editor = prefs.edit(); editor.putString(sharedPrefFiFi, firstField); editor.putString(sharedPrefSeFi, secondField); editor.apply(); openWebView(); } }).setNegativeButton(getString(android.R.string.cancel), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int whichButton) { WebView2.this.finish(); } }).show(); }
From source file:de.nico.asura.activities.WebView3.java
private void checkLogin() { // Layout for Dialog final LinearLayout layout = new LinearLayout(this); layout.setOrientation(LinearLayout.VERTICAL); final EditText edit_name = new EditText(this); edit_name.setHint(getString(R.string.menu_Web_3_auth_fiFi)); layout.addView(edit_name);//w ww .j a va 2 s . com final EditText edit_pass = new EditText(this); edit_pass.setHint(getString(R.string.menu_Web_3_auth_seFi)); edit_pass.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD); layout.addView(edit_pass); final Builder builder = new Builder(this); builder.setTitle(getString(R.string.menu_Web_3_name)).setCancelable(false).setView(layout) .setPositiveButton(getString(android.R.string.ok), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int whichButton) { firstField = edit_name.getText().toString(); secondField = edit_pass.getText().toString(); // Nothing? if (firstField.length() == 0 || secondField.length() == 0) { Utils.makeShortToast(WebView3.this, getString(R.string.wrong)); checkLogin(); return; } final Editor editor = prefs.edit(); editor.putString(sharedPrefFiFi, firstField); editor.putString(sharedPrefSeFi, secondField); editor.apply(); openWebView(); } }).setNegativeButton(getString(android.R.string.cancel), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int whichButton) { WebView3.this.finish(); } }).show(); }
From source file:com.upmoon.alexanderbean.barcrawlr.fragments.PlanSelectorFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.fragment_plan_selector, container, false); /**/*from w w w.ja v a 2 s. co m*/ * Widgets here */ mLeftFAB = (FloatingActionButton) v.findViewById(R.id.connect_fab); mLeftFAB.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { AlertDialog.Builder buildo = new AlertDialog.Builder(getActivity()); final EditText inp1 = new EditText(getActivity()); inp1.setInputType(InputType.TYPE_CLASS_TEXT); buildo.setTitle("Join Active Plan"); buildo.setView(inp1); buildo.setPositiveButton("Join", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface diag, int which) { AlertDialog.Builder buildo = new AlertDialog.Builder(getActivity()); final EditText inp2 = new EditText(getActivity()); inp2.setInputType(InputType.TYPE_CLASS_TEXT); buildo.setTitle("Choose a username"); buildo.setView(inp2); buildo.setPositiveButton("Join", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface diag, int which) { if (!inp2.getText().toString().equals("")) { GetPlan gp = new GetPlan(); gp.execute(inp1.getText().toString(), inp2.getText().toString()); } } }); buildo.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface diag, int which) { diag.cancel(); } }); buildo.show(); } }); buildo.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface diag, int which) { diag.cancel(); } }); buildo.show(); } }); mRightFAB = (FloatingActionButton) v.findViewById(R.id.new_plan_fab); mRightFAB.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { AlertDialog.Builder buildo = new AlertDialog.Builder(getActivity()); final EditText inp = new EditText(getActivity()); inp.setInputType(InputType.TYPE_CLASS_TEXT); buildo.setTitle("Create New Plan"); buildo.setView(inp); buildo.setPositiveButton("Create", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface diag, int which) { PlanLoader pl = new PlanLoader(getActivity()); String planName = inp.getText().toString(); if (!planName.equals("") && pl.planNameExists(planName)) { Toast.makeText(getActivity(), "Invalid Name or name exists", Toast.LENGTH_SHORT).show(); } else { Plan plan = new Plan(); plan.setName(inp.getText().toString()); CurrentPlan.getInstance().setPlan(plan); Intent intent = new Intent(getActivity(), PlanCreator.class); startActivity(intent); } } }); buildo.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface diag, int which) { } }); buildo.show(); } }); //RecyclerView mAdapter = new PlanAdapter(); mRecyclerView = (RecyclerView) v.findViewById(R.id.gol_recycler_view); mRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false)); mRecyclerView.setAdapter(mAdapter); /** * Load in plan data */ PlanListChanged(); /** * location */ locationManager = (LocationManager) getActivity().getSystemService(Context.LOCATION_SERVICE); locationListener = new LocationListener() { public void onLocationChanged(Location location) { // Called when a new location is found by the network location provider. updateLocation(location.getLongitude(), location.getLatitude()); } public void onStatusChanged(String provider, int status, Bundle extras) { } public void onProviderEnabled(String provider) { } public void onProviderDisabled(String provider) { } }; return v; }
From source file:co.ldln.android.ObjectCreateFragment.java
@Override public void onReadSchemaResult(final Schema schema) { mTextFields = new ArrayList<EditText>(); // Create the form based on the schema fields List<SchemaField> fieldList = new ArrayList<SchemaField>(); fieldList.addAll(schema.getFields(mActivity)); Collections.sort(fieldList);//from w w w. j a va 2 s . c o m for (SchemaField field : fieldList) { String type = field.getType(); String label = field.getLabel(); // Create a linear layout to hold the field LinearLayout ll = new LinearLayout(mActivity); LayoutParams llParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); ll.setLayoutParams(llParams); ll.setOrientation(LinearLayout.HORIZONTAL); // TODO: different UI for different field types // Default to EditText EditText et = new EditText(mActivity); LayoutParams etParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); et.setLayoutParams(etParams); et.setHint(label); if (type.equals("map_location")) et.setText(mMapLocation); ll.addView(et); mTextFields.add(et); mFormHolder.addView(ll); } // Add submit button Button b = new Button(mActivity); LayoutParams bParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); b.setText("Save"); b.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { try { String kvPairs = ""; JSONObject kvPairsJsonObject = new JSONObject(); for (EditText et : mTextFields) { String key = et.getHint().toString(); String value = et.getText().toString(); kvPairsJsonObject.put(key, value); } kvPairs = kvPairsJsonObject.toString(); LDLN.saveSyncableObject(mActivity, ObjectCreateFragment.this, schema.getKey(), kvPairs); } catch (JSONException e) { e.printStackTrace(); onSaveSyncableObjectResult(false); } } }); mFormHolder.addView(b); Toast.makeText(mActivity, "This is a form that's dynamically generated from a syncable object schema. It will soon have handling for dynamic form elements (photo, latlon picker, etc).", Toast.LENGTH_LONG).show(); }