Java Code Examples for android.support.v7.widget.AppCompatEditText#setText()
The following examples show how to use
android.support.v7.widget.AppCompatEditText#setText() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: UserInfoFragment.java From AccountBook with GNU General Public License v3.0 | 6 votes |
/** * 显示修改用户名 Dialog */ @Override public void showUpdateUsernameDialog() { // 回显用户名 final AppCompatEditText editText = new AppCompatEditText(mContext); String username = mCilUsername.getRightText(); editText.setText(username); new AlertDialog.Builder(mContext) .setTitle(UiUtils.getString(R.string.dialog_title_update_username)) .setView(editText, DimenUtils.dp2px(15f), DimenUtils.dp2px(15f), DimenUtils.dp2px(15f), DimenUtils.dp2px(15f)) .setNegativeButton(UiUtils.getString(R.string.dialog_cancel), null) .setPositiveButton(UiUtils.getString(R.string.dialog_affirm), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { String newUsername = editText.getText().toString(); if(TextUtils.isEmpty(newUsername) || newUsername.length() > 16){ ToastUtils.show(mContext, UiUtils.getString(R.string.toast_username_length)); }else{ User user = UserUtils.getUser(); user.setUsername(newUsername); ProgressUtils.show(mContext, UiUtils.getString(R.string.load_update)); mPresenter.saveUserInfo(user); } } }).create().show(); }
Example 2
Source File: TodoListActivity.java From TodoFluxArchitecture with Apache License 2.0 | 6 votes |
private void showEditDialog(TodoItem item) { View customView = LayoutInflater.from(this).inflate(R.layout.dialog_todo_edit, null); final AppCompatEditText editText = ButterKnife.findById(customView, R.id.inputEditText); editText.setText(item.getDescription()); editText.setSelection(item.getDescription().length()); materialDialog = new MaterialDialog.Builder(this) .customView(customView, false) .positiveColorRes(R.color.positive_color) .negativeColorRes(R.color.positive_color) .positiveText(R.string.action_sure) .negativeText(R.string.action_cancel) .onPositive((dialog, which) -> { String text = editText.getText().toString(); if (!TextUtils.isEmpty(text)) { actionCreator.createItemEditAction(item.getId(), text, item.isCompleted(), item.isStared()); dialog.dismiss(); } }) .build(); materialDialog.show(); }
Example 3
Source File: Term.java From Ansole with GNU General Public License v2.0 | 6 votes |
private void doRenameWindow() { final AppCompatEditText editText = new AppCompatEditText(this); editText.setText(getCurrentTermSession().getTitle()); final AlertDialog.Builder b = new AlertDialog.Builder(this); b.setTitle(R.string.input_window_title); b.setView(editText); b.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface arg0, int arg1) { doChangeWindowTitle(editText.getText().toString()); } }); b.setNegativeButton(android.R.string.no, null); b.show(); }
Example 4
Source File: IpInputEditText.java From v9porn with MIT License | 5 votes |
private void pressTextChange(Editable s, AppCompatEditText currenAppCompatEditText, AppCompatEditText preFouceAppCompatEditText, AppCompatEditText nextFouceAppCompatEditText) { String text = s.toString(); //回退上一个 if (TextUtils.isEmpty(s)) { focusEditViewAndMoveSelection(preFouceAppCompatEditText); return; } if (!text.startsWith(ZERO_WIDTH_SPACE)) { text = text.replace(ZERO_WIDTH_SPACE, ""); text = ZERO_WIDTH_SPACE + text; currenAppCompatEditText.setText(text); moveSelectionToLast(currenAppCompatEditText); } //输入未达到最大,但包含点,则说明当前输入完成 if (text.contains(POINT_STR)) { //替换掉点,重新设置文本 text = text.replace(POINT_STR, ""); currenAppCompatEditText.setText(text); if (!TextUtils.isEmpty(text.replace(ZERO_WIDTH_SPACE, ""))) { //聚焦到下一个控件 focusEditViewAndMoveSelection(nextFouceAppCompatEditText); } //达到最大,输入完成 } else if (text.length() >= SUB_MAX_LENGTH) { int subIp = Integer.parseInt(text.replace(ZERO_WIDTH_SPACE, "")); //检查ip断合法性 if (subIp >= MAX_IP_NUM) { //清空重新输入 currenAppCompatEditText.setText(ZERO_WIDTH_SPACE); } else { //验证通过,聚焦到下一个控件 focusEditViewAndMoveSelection(nextFouceAppCompatEditText); } } }
Example 5
Source File: WelcomeActivity.java From cashuwallet with MIT License | 5 votes |
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == AUTHENTICATION_SCREEN_REQUEST_CODE) { if (resultCode == RESULT_OK) { cont.run(); } else { if (progressDialog.isShowing()) progressDialog.dismiss(); setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED); mnemonicLayout.setEnabled(true); passwordLayout.setEnabled(true); } } if (requestCode == CAPTURE_SCREEN_REQUEST_CODE && resultCode == RESULT_OK && data != null) { String result = data.getStringExtra("result"); String message = data.getStringExtra("message"); if (result != null) { AppCompatEditText mnemonicView = rootView.findViewById(R.id.mnemonic); mnemonicView.setText(result); } if (message != null) { Snackbar.make(rootView, message, Snackbar.LENGTH_LONG).show(); } } }
Example 6
Source File: UseFragment.java From cashuwallet with MIT License | 5 votes |
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == AUTHENTICATION_SCREEN_REQUEST_CODE) { if (resultCode == RESULT_OK) { cont.run(); } else { if (signingDialog.isShowing()) signingDialog.dismiss(); getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED); targetAddressLayout.setEnabled(true); amountLayout.setEnabled(true); } } if (requestCode == CAPTURE_SCREEN_REQUEST_CODE && resultCode == RESULT_OK && data != null) { String result = data.getStringExtra("result"); String message = data.getStringExtra("message"); if (result != null) { AppCompatEditText textView = rootView.findViewById(R.id.target_address); textView.setText(result); } if (message != null) { Snackbar.make(rootView, message, Snackbar.LENGTH_LONG).show(); } } }
Example 7
Source File: IpInputEditText.java From v9porn with MIT License | 5 votes |
private void pressTextChange(Editable s, AppCompatEditText currenAppCompatEditText, AppCompatEditText preFouceAppCompatEditText, AppCompatEditText nextFouceAppCompatEditText) { String text = s.toString(); //回退上一个 if (TextUtils.isEmpty(s)) { focusEditViewAndMoveSelection(preFouceAppCompatEditText); return; } if (!text.startsWith(ZERO_WIDTH_SPACE)) { text = text.replace(ZERO_WIDTH_SPACE, ""); text = ZERO_WIDTH_SPACE + text; currenAppCompatEditText.setText(text); moveSelectionToLast(currenAppCompatEditText); } //输入未达到最大,但包含点,则说明当前输入完成 if (text.contains(POINT_STR)) { //替换掉点,重新设置文本 text = text.replace(POINT_STR, ""); currenAppCompatEditText.setText(text); if (!TextUtils.isEmpty(text.replace(ZERO_WIDTH_SPACE, ""))) { //聚焦到下一个控件 focusEditViewAndMoveSelection(nextFouceAppCompatEditText); } //达到最大,输入完成 } else if (text.length() >= SUB_MAX_LENGTH) { int subIp = Integer.parseInt(text.replace(ZERO_WIDTH_SPACE, "")); //检查ip断合法性 if (subIp >= MAX_IP_NUM) { //清空重新输入 currenAppCompatEditText.setText(ZERO_WIDTH_SPACE); } else { //验证通过,聚焦到下一个控件 focusEditViewAndMoveSelection(nextFouceAppCompatEditText); } } }
Example 8
Source File: FragmentMatrixInput.java From ncalc with GNU General Public License v3.0 | 5 votes |
private void createLayoutMatrix(int col, int row, ViewGroup viewGroup) { viewGroup.removeAllViews(); @IdRes int index = 1; for (int i = 0; i < row; i++) { for (int j = 0; j < col; j++) { AppCompatEditText editText = new AppCompatEditText(getContext()); editText.setHint("[" + i + "," + j + "]"); RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); editText.setSingleLine(true); editText.setInputType(InputType.TYPE_NUMBER_FLAG_DECIMAL); editText.setId(index); if (isDebug) { editText.setText(String.valueOf(random.nextInt(200) - 100)); } if (j == 0) { params.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE); } else { params.addRule(RelativeLayout.RIGHT_OF, index - 1); } if (i == 0) { params.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE); } else { params.addRule(RelativeLayout.BELOW, index - col); } editText.setLayoutParams(params); viewGroup.addView(editText); index++; } } }
Example 9
Source File: EditTextActivity.java From KA27 with Apache License 2.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); editText = (AppCompatEditText) findViewById(R.id.edittext); editText.setTextColor(ContextCompat.getColor(this, Utils.DARKTHEME ? R.color.white : R.color.black)); if ((originalText = getIntent().getExtras().getString(TEXT_ARG)) != null) editText.setText(originalText); ActionBar actionBar; if ((name = getIntent().getExtras().getString(NAME_ARG)) != null && (actionBar = getSupportActionBar()) != null) actionBar.setTitle(name); }
Example 10
Source File: EditTextActivity.java From kernel_adiutor with Apache License 2.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); editText = (AppCompatEditText) findViewById(R.id.edittext); editText.setTextColor(getResources().getColor(Utils.DARKTHEME ? R.color.white : R.color.black)); if ((originalText = getIntent().getExtras().getString(TEXT_ARG)) != null) editText.setText(originalText); ActionBar actionBar; if ((name = getIntent().getExtras().getString(NAME_ARG)) != null && (actionBar = getSupportActionBar()) != null) actionBar.setTitle(name); }
Example 11
Source File: MarkdownNoteEditActivity.java From nono-android with GNU General Public License v3.0 | 5 votes |
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView=null; final String content = getArguments().getString(ARG_CONTENT); switch (getArguments().getInt(ARG_SECTION_NUMBER)) { case TYPE_EDIT: showHelp(container); rootView = inflater.inflate(R.layout.fragment_markdown, container, false); edit =(AppCompatEditText) rootView.findViewById(R.id.markdown_edit); edit.requestFocus(); if(content !=null){ edit.setText(content); historyList.add(new History(0,content)); } edit.addTextChangedListener(textWatcher); break; case TYPE_VIEW: showHelp(container); rootView=inflater.inflate(R.layout.fragment_webview,container,false); webView=(MarkDownWebView) rootView.findViewById(R.id.web_view); webView.ini(); webView.setBackgroundColor(AppPreferenceUtil.getEditBgColor()); webView.loadUrl("file:///android_asset/markdown.html"); webView.postDelayed(new Runnable() { @Override public void run() { parseMarkdown(content); getView().findViewById(R.id.loading_bg).setVisibility(View.GONE); getView().findViewById(R.id.actual_view).setVisibility(View.VISIBLE); } },300); } return rootView; }
Example 12
Source File: FTPServerFragment.java From PowerFileExplorer with GNU General Public License v3.0 | 4 votes |
private void initLoginDialogViews(View loginDialogView) { usernameEditText = (AppCompatEditText) loginDialogView.findViewById(R.id.edit_text_dialog_ftp_username); passwordEditText = (AppCompatEditText) loginDialogView.findViewById(R.id.edit_text_dialog_ftp_password); usernameTextInput = (TextInputLayout) loginDialogView.findViewById(R.id.text_input_dialog_ftp_username); passwordTextInput = (TextInputLayout) loginDialogView.findViewById(R.id.text_input_dialog_ftp_password); mAnonymousCheckBox = (AppCompatCheckBox) loginDialogView.findViewById(R.id.checkbox_ftp_anonymous); mSecureCheckBox = (AppCompatCheckBox) loginDialogView.findViewById(R.id.checkbox_ftp_secure); mAnonymousCheckBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { usernameEditText.setEnabled(false); passwordEditText.setEnabled(false); } else { usernameEditText.setEnabled(true); passwordEditText.setEnabled(true); } } }); // init dialog views as per preferences if (getUsernameFromPreferences().equals(FTPService.DEFAULT_USERNAME)) { mAnonymousCheckBox.setChecked(true); } else { usernameEditText.setText(getUsernameFromPreferences()); passwordEditText.setText(getPasswordFromPreferences()); } if (getSecurePreference()) { mSecureCheckBox.setChecked(true); } else { mSecureCheckBox.setChecked(false); } // check if we have a keystore InputStream stream = getResources().openRawResource(R.raw.explorer); if (stream == null) { mSecureCheckBox.setEnabled(false); mSecureCheckBox.setChecked(false); setSecurePreference(false); } }
Example 13
Source File: l.java From stynico with MIT License | 4 votes |
private void initView() { toolbar = (android.support.v7.widget.Toolbar)findViewById(R.id.toolbar); setSupportActionBar(toolbar); ediContent = (AppCompatEditText) findViewById(R.id.id_lxw_push_content); scrollPicContent = (HorizontalScrollView) findViewById(R.id.id_lxw_push_scrollPicContent); layPicContent = (LinearLayout) findViewById(R.id.id_lxw_push_layPicContent); btnCamera = (LinearLayout) findViewById(R.id.id_lxw_push_btn_btnCamera); btnEmotion = (LinearLayout) findViewById(R.id.id_lxw_push_btn_btnEmotion); btnSend = (LinearLayout) findViewById(R.id.btnSend); emojPager = (ViewPager) findViewById(R.id.id_lxw_push_emoj_viewpager); SharedPreferences sharedPreferencesb = getSharedPreferences("fba", AppCompatActivity.MODE_PRIVATE); String r = sharedPreferencesb.getString("stytoolpro", ""); ediContent.setText(r); }
Example 14
Source File: CreateConnectionFragment.java From FireFiles with Apache License 2.0 | 4 votes |
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { final Context context = getActivity(); final AlertDialog.Builder builder = new AlertDialog.Builder(context); final LayoutInflater dialogInflater = getActivity().getLayoutInflater(); final View view = dialogInflater.inflate(R.layout.dialog_create_connection, null, false); name = (AppCompatEditText) view.findViewById(R.id.name); host = (AppCompatEditText) view.findViewById(R.id.host); port = (AppCompatEditText) view.findViewById(R.id.port); path = (AppCompatEditText) view.findViewById(R.id.path); hostContainer = view.findViewById(R.id.hostContainer); pathContainer = view.findViewById(R.id.pathContainer); username = (AppCompatEditText) view.findViewById(R.id.username); usernameContainer = view.findViewById(R.id.usernameContainer); password = (AppCompatEditText) view.findViewById(R.id.password); passwordContainer = view.findViewById(R.id.passwordContainer); scheme = (AppCompatSpinner) view.findViewById(R.id.scheme); anonymous = (AppCompatCheckBox) view.findViewById(R.id.anonymous); anonymous.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean b) { usernameContainer.setVisibility(b ? View.GONE : View.VISIBLE); passwordContainer.setVisibility(b ? View.GONE : View.VISIBLE); } }); if(connection_id != 0){ NetworkConnection connection = NetworkConnection.fromConnectionId(getActivity(), connection_id); ArrayAdapter myAdap = (ArrayAdapter) scheme.getAdapter(); int spinnerPosition = myAdap.getPosition(connection.getScheme().toUpperCase()); scheme.setSelection(spinnerPosition); name.setText(connection.getName()); host.setText(connection.getHost()); port.setText(Integer.toString(connection.getPort())); path.setText(connection.getPath()); username.setText(connection.getUserName()); password.setText(connection.getPassword()); anonymous.setChecked(connection.isAnonymousLogin()); if(SERVER.equals(connection.getType())){ hostContainer.setVisibility(View.GONE); pathContainer.setVisibility(View.VISIBLE); } } builder.setTitle( (connection_id == 0 ? "New" : "Edit") + " Connection"); builder.setView(view); builder.setPositiveButton(connection_id == 0 ? "ADD" : "SAVE", new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { final BaseActivity activity = (BaseActivity) getActivity(); NetworkConnection networkConnection = getNetworkConnection(); if(validate(networkConnection)){ new CreateConnectionTask(activity, networkConnection).executeOnExecutor( ProviderExecutor.forAuthority(ExplorerProvider.AUTHORITY)); } } }); builder.setNegativeButton(android.R.string.cancel, null); return builder.create(); }
Example 15
Source File: CreateConnectionFragment.java From FireFiles with Apache License 2.0 | 4 votes |
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { final Context context = getActivity(); final AlertDialog.Builder builder = new AlertDialog.Builder(context); final LayoutInflater dialogInflater = getActivity().getLayoutInflater(); final View view = dialogInflater.inflate(R.layout.dialog_create_connection, null, false); name = (AppCompatEditText) view.findViewById(R.id.name); host = (AppCompatEditText) view.findViewById(R.id.host); port = (AppCompatEditText) view.findViewById(R.id.port); path = (AppCompatEditText) view.findViewById(R.id.path); hostContainer = view.findViewById(R.id.hostContainer); pathContainer = view.findViewById(R.id.pathContainer); username = (AppCompatEditText) view.findViewById(R.id.username); usernameContainer = view.findViewById(R.id.usernameContainer); password = (AppCompatEditText) view.findViewById(R.id.password); passwordContainer = view.findViewById(R.id.passwordContainer); scheme = (AppCompatSpinner) view.findViewById(R.id.scheme); anonymous = (AppCompatCheckBox) view.findViewById(R.id.anonymous); anonymous.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean b) { usernameContainer.setVisibility(b ? View.GONE : View.VISIBLE); passwordContainer.setVisibility(b ? View.GONE : View.VISIBLE); } }); if(connection_id != 0){ NetworkConnection connection = NetworkConnection.fromConnectionId(getActivity(), connection_id); ArrayAdapter myAdap = (ArrayAdapter) scheme.getAdapter(); int spinnerPosition = myAdap.getPosition(connection.getScheme().toUpperCase()); scheme.setSelection(spinnerPosition); name.setText(connection.getName()); host.setText(connection.getHost()); port.setText(Integer.toString(connection.getPort())); path.setText(connection.getPath()); username.setText(connection.getUserName()); password.setText(connection.getPassword()); anonymous.setChecked(connection.isAnonymousLogin()); if(SERVER.equals(connection.getType())){ hostContainer.setVisibility(View.GONE); pathContainer.setVisibility(View.VISIBLE); } } builder.setTitle( (connection_id == 0 ? "New" : "Edit") + " Connection"); builder.setView(view); builder.setPositiveButton(connection_id == 0 ? "ADD" : "SAVE", new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { final BaseActivity activity = (BaseActivity) getActivity(); NetworkConnection networkConnection = getNetworkConnection(); if(validate(networkConnection)){ new CreateConnectionTask(activity, networkConnection).executeOnExecutor( ProviderExecutor.forAuthority(ExplorerProvider.AUTHORITY)); } } }); builder.setNegativeButton(android.R.string.cancel, null); return builder.create(); }
Example 16
Source File: CreateConnectionFragment.java From FireFiles with Apache License 2.0 | 4 votes |
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { final Context context = getActivity(); final AlertDialog.Builder builder = new AlertDialog.Builder(context); final LayoutInflater dialogInflater = getActivity().getLayoutInflater(); final View view = dialogInflater.inflate(R.layout.dialog_create_connection, null, false); name = (AppCompatEditText) view.findViewById(R.id.name); host = (AppCompatEditText) view.findViewById(R.id.host); port = (AppCompatEditText) view.findViewById(R.id.port); path = (AppCompatEditText) view.findViewById(R.id.path); hostContainer = view.findViewById(R.id.hostContainer); pathContainer = view.findViewById(R.id.pathContainer); username = (AppCompatEditText) view.findViewById(R.id.username); usernameContainer = view.findViewById(R.id.usernameContainer); password = (AppCompatEditText) view.findViewById(R.id.password); passwordContainer = view.findViewById(R.id.passwordContainer); scheme = (AppCompatSpinner) view.findViewById(R.id.scheme); anonymous = (AppCompatCheckBox) view.findViewById(R.id.anonymous); anonymous.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean b) { usernameContainer.setVisibility(b ? View.GONE : View.VISIBLE); passwordContainer.setVisibility(b ? View.GONE : View.VISIBLE); } }); if(connection_id != 0){ NetworkConnection connection = NetworkConnection.fromConnectionId(getActivity(), connection_id); ArrayAdapter myAdap = (ArrayAdapter) scheme.getAdapter(); int spinnerPosition = myAdap.getPosition(connection.getScheme().toUpperCase()); scheme.setSelection(spinnerPosition); name.setText(connection.getName()); host.setText(connection.getHost()); port.setText(Integer.toString(connection.getPort())); path.setText(connection.getPath()); username.setText(connection.getUserName()); password.setText(connection.getPassword()); anonymous.setChecked(connection.isAnonymousLogin()); if(SERVER.equals(connection.getType())){ hostContainer.setVisibility(View.GONE); pathContainer.setVisibility(View.VISIBLE); } } builder.setTitle( (connection_id == 0 ? "New" : "Edit") + " Connection"); builder.setView(view); builder.setPositiveButton(connection_id == 0 ? "ADD" : "SAVE", new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { final BaseActivity activity = (BaseActivity) getActivity(); NetworkConnection networkConnection = getNetworkConnection(); if(validate(networkConnection)){ new CreateConnectionTask(activity, networkConnection).executeOnExecutor( ProviderExecutor.forAuthority(ExplorerProvider.AUTHORITY)); } } }); builder.setNegativeButton(android.R.string.cancel, null); return builder.create(); }