List of usage examples for android.text Editable toString
public String toString();
From source file:org.alfresco.mobile.android.application.fragments.fileexplorer.FileNameDialogFragment.java
public Dialog onCreateDialog(Bundle savedInstanceState) { // Init File/* w w w. jav a 2s .c o m*/ if (getArguments().containsKey(ARGUMENT_FILE_RENAME)) { fileToRename = (File) getArguments().get(ARGUMENT_FILE_RENAME); } parentFile = (File) getArguments().get(ARGUMENT_FOLDER); String title = null; if (fileToRename != null) { title = getString(R.string.action_rename) + " : " + fileToRename.getName(); } else { title = getString(R.string.folder_create); } LayoutInflater inflater = LayoutInflater.from(getActivity()); final View v = inflater.inflate(R.layout.app_create_document, (ViewGroup) this.getView()); final MaterialEditText textName = ((MaterialEditText) v.findViewById(R.id.document_name)); if (fileToRename != null) { textName.setText("." + IOUtils.extractFileExtension(fileToRename.getName())); } textName.addTextChangedListener(new TextWatcher() { public void afterTextChanged(Editable s) { if (s.length() > 0) { ((MaterialDialog) getDialog()).getActionButton(DialogAction.POSITIVE).setEnabled(true); if (UIUtils.hasInvalidName(s.toString().trim())) { textName.setError(getString(R.string.filename_error_character)); ((MaterialDialog) getDialog()).getActionButton(DialogAction.POSITIVE).setEnabled(false); } else if ((new File(parentFile, s.toString().trim()).exists())) { textName.setError(getString(R.string.create_document_filename_error)); ((MaterialDialog) getDialog()).getActionButton(DialogAction.POSITIVE).setEnabled(false); } else { textName.setError(null); } } else { ((MaterialDialog) getDialog()).getActionButton(DialogAction.POSITIVE).setEnabled(false); textName.setError(null); } } public void beforeTextChanged(CharSequence s, int start, int count, int after) { } public void onTextChanged(CharSequence s, int start, int before, int count) { } }); MaterialDialog dialog = new MaterialDialog.Builder(getActivity()).iconRes(R.drawable.ic_application_logo) .title(title).customView(v, true) .positiveText((fileToRename != null) ? R.string.ok : R.string.create).negativeText(R.string.cancel) .callback(new MaterialDialog.ButtonCallback() { @Override public void onNegative(MaterialDialog dialog) { dialog.dismiss(); } @Override public void onPositive(MaterialDialog dialog) { UIUtils.hideKeyboard(getActivity()); if (fileToRename != null) { String operationId = Operator.with(getActivity()) .load(new RenameFileRequest.Builder(fileToRename, textName.getText().toString().trim()) .setNotificationVisibility(OperationRequest.VISIBILITY_DIALOG)); OperationWaitingDialogFragment .newInstance(CreateDirectoryRequest.TYPE_ID, R.drawable.ic_edit, getString(R.string.action_rename), null, null, 0, operationId) .show(getActivity().getSupportFragmentManager(), OperationWaitingDialogFragment.TAG); } else { String operationId = Operator.with(getActivity()) .load(new CreateDirectoryRequest.Builder( (File) getArguments().get(ARGUMENT_FOLDER), textName.getText().toString().trim()) .setNotificationVisibility(OperationRequest.VISIBILITY_DIALOG)); OperationWaitingDialogFragment .newInstance(CreateDirectoryRequest.TYPE_ID, R.drawable.ic_add_folder, getString(R.string.folder_create), null, null, 0, operationId) .show(getActivity().getSupportFragmentManager(), OperationWaitingDialogFragment.TAG); } dismiss(); } }).build(); dialog.getActionButton(DialogAction.POSITIVE).setEnabled(false); return dialog; }
From source file:com.bdcorps.videonews.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Intent intent = getIntent();/*from w w w . j av a 2 s. com*/ topicCode = intent.getStringExtra("topicCode"); //if it's a string you stored. //CCT Connection mConnection = new CustomTabsServiceConnection() { @Override public void onCustomTabsServiceConnected(ComponentName componentName, CustomTabsClient customTabsClient) { mClient = customTabsClient; mCustomTabsSession = getSession(); mClient.warmup(0); } @Override public void onServiceDisconnected(ComponentName componentName) { mClient = null; mCustomTabsSession = null; } }; //Bind CCT Service String packageName = "com.android.chrome"; CustomTabsClient.bindCustomTabsService(this, packageName, mConnection); text = (TextView) findViewById(R.id.textview); img = (ImageView) findViewById(R.id.imageview); titleTextView = (TextView) findViewById(R.id.title_text_view); mTts = new TextToSpeech(this, this); Button b1 = (Button) findViewById(R.id.button); b1.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { grabnews(topicCode); } }); Button b2 = (Button) findViewById(R.id.button2); b2.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { speak(text.getText().toString()); } }); Button b3 = (Button) findViewById(R.id.button3); b3.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { article++; grabnews(topicCode); } }); text.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) { } @Override public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) { } @Override public void afterTextChanged(Editable editable) { Log.i("SSS", "text on board is =" + editable.toString()); speak(text.getText().toString()); } }); }
From source file:com.forrestguice.suntimeswidget.settings.ColorChooser.java
@Override public void afterTextChanged(Editable editable) { if (isRunning || isRemoving) return;/*from ww w . java 2s . co m*/ isRunning = true; String text = editable.toString(); // should consist of [#][0-9][a-f] for (int j = text.length() - 1; j >= 0; j--) { if (!inputSet.contains(text.charAt(j))) { editable.delete(j, j + 1); } } text = editable.toString(); // should start with a # int i = text.indexOf('#'); if (i != -1) { editable.delete(i, i + 1); } editable.insert(0, "#"); if (editable.length() > 8) // should be no longer than 8 { editable.delete(9, editable.length()); } text = editable.toString(); String toCaps = text.toUpperCase(Locale.US); editable.clear(); editable.append(toCaps); isRunning = false; }
From source file:com.entertailion.android.launcher.Dialogs.java
/** * Change the name of the current row/* w w w.jav a 2 s . co 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.appsimobile.appsii.hotspotmanager.HotspotSettingsFragment.java
@Override public void afterTextChanged(Editable s) { mHandler.removeMessages(0);/*w w w .j a v a 2 s. com*/ Message message = mHandler.obtainMessage(0, s.toString()); mHandler.sendMessageDelayed(message, 500); }
From source file:org.mariotaku.twidere.fragment.DMConversationFragment.java
@Override public void onClick(View view) { switch (view.getId()) { case R.id.send: { final Editable text = mEditText.getText(); if (text == null) return; final String message = text.toString(); if (mValidator.isValidTweet(message)) { final long account_id = mArguments.getLong(INTENT_KEY_ACCOUNT_ID, -1); final long conversation_id = mArguments.getLong(INTENT_KEY_CONVERSATION_ID, -1); final String screen_name = mArguments.getString(INTENT_KEY_SCREEN_NAME); mService.sendDirectMessage(account_id, screen_name, conversation_id, message); text.clear();/*from w ww .j ava 2 s .co m*/ } break; } case R.id.screen_name_confirm: { final CharSequence text = mEditScreenName.getText(); if (text == null) return; final String screen_name = text.toString(); mArguments.putString(INTENT_KEY_SCREEN_NAME, screen_name); getLoaderManager().restartLoader(0, mArguments, this); break; } } }
From source file:org.thoughtcrime.securesms.scribbles.widget.MotionView.java
@Override public void afterTextChanged(Editable s) { String text = s.toString(); MotionEntity entity = getSelectedEntity(); if (entity != null && entity instanceof TextEntity) { TextEntity textEntity = (TextEntity) entity; if (!textEntity.getLayer().getText().equals(text)) { textEntity.getLayer().setText(text); textEntity.updateEntity();/*from w w w . j av a 2 s . c o m*/ MotionView.this.invalidate(); } } }
From source file:com.irccloud.android.activity.PastebinEditorActivity.java
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (Build.VERSION.SDK_INT >= 21) { Bitmap cloud = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher); setTaskDescription(new ActivityManager.TaskDescription(getResources().getString(R.string.app_name), cloud, 0xFFF2F7FC));/*from w ww . j a v a 2s . co m*/ cloud.recycle(); } setContentView(R.layout.activity_pastebineditor); toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); if (getSupportActionBar() != null) { if (!getWindow().isFloating()) { getSupportActionBar().setDisplayShowHomeEnabled(true); getSupportActionBar().setDisplayHomeAsUpEnabled(true); } } paste = (EditText) findViewById(R.id.paste); filename = (EditText) findViewById(R.id.filename); message = (EditText) findViewById(R.id.message); messages_count = (TextView) findViewById(R.id.messages_count); if (savedInstanceState != null && savedInstanceState.containsKey("message")) message.setText(savedInstanceState.getString("message")); if (savedInstanceState != null && savedInstanceState.containsKey("paste_id")) pasteID = savedInstanceState.getString("paste_id"); else if (getIntent() != null && getIntent().hasExtra("paste_id")) pasteID = getIntent().getStringExtra("paste_id"); if (savedInstanceState != null && savedInstanceState.containsKey("paste_contents")) pastecontents = savedInstanceState.getString("paste_contents"); else if (getIntent() != null && getIntent().hasExtra("paste_contents")) pastecontents = getIntent().getStringExtra("paste_contents"); paste.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) { } @Override public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) { } @Override public void afterTextChanged(Editable editable) { int count = 0; String lines[] = editable.toString().split("\n"); for (String line : lines) { count += Math.ceil(line.length() / 1080.0f); } messages_count.setText("Text will be sent as " + count + " message" + (count == 1 ? "" : "s")); } }); paste.setText(pastecontents); if (savedInstanceState != null && savedInstanceState.containsKey("filename")) filename.setText(savedInstanceState.getString("filename")); else if (getIntent() != null && getIntent().hasExtra("filename")) filename.setText(getIntent().getStringExtra("filename")); tabHost = (TabLayout) findViewById(android.R.id.tabhost); ViewCompat.setElevation(toolbar, ViewCompat.getElevation(tabHost)); if (pasteID != null) { tabHost.setVisibility(View.GONE); message.setVisibility(View.GONE); findViewById(R.id.message_heading).setVisibility(View.GONE); } else { tabHost.setTabGravity(TabLayout.GRAVITY_FILL); tabHost.setTabMode(TabLayout.MODE_FIXED); tabHost.addTab(tabHost.newTab().setText("Pastebin")); tabHost.addTab(tabHost.newTab().setText("Messages")); tabHost.setOnTabSelectedListener(new TabLayout.OnTabSelectedListener() { @Override public void onTabSelected(TabLayout.Tab tab) { current_tab = tab.getPosition(); if (current_tab == 0) { filename.setVisibility(View.VISIBLE); message.setVisibility(View.VISIBLE); messages_count.setVisibility(View.GONE); findViewById(R.id.filename_heading).setVisibility(View.VISIBLE); findViewById(R.id.message_heading).setVisibility(View.VISIBLE); } else { filename.setVisibility(View.GONE); message.setVisibility(View.GONE); messages_count.setVisibility(View.VISIBLE); findViewById(R.id.filename_heading).setVisibility(View.GONE); findViewById(R.id.message_heading).setVisibility(View.GONE); } } @Override public void onTabUnselected(TabLayout.Tab tab) { } @Override public void onTabReselected(TabLayout.Tab tab) { } }); if (savedInstanceState != null && savedInstanceState.containsKey("tab")) tabHost.getTabAt(savedInstanceState.getInt("tab")).select(); } NetworkConnection.getInstance().addHandler(this); if (pasteID != null && (pastecontents == null || pastecontents.length() == 0)) { new FetchPastebinTask().execute((Void) null); } if (pasteID != null) { setTitle(R.string.title_activity_pastebin_editor_edit); toolbar.setBackgroundResource(R.drawable.actionbar); } else { setTitle(R.string.title_activity_pastebin_editor); } supportInvalidateOptionsMenu(); result(RESULT_CANCELED); }
From source file:com.app.jdy.ui.CashAdvanceActivity.java
public void initView() { backBtn = (ImageView) findViewById(R.id.back_img); right_img = (ImageView) findViewById(R.id.right_img); backBtn.setVisibility(View.VISIBLE); right_img.setVisibility(View.VISIBLE); right_img.setBackgroundResource(R.drawable.withdrawcash_history); backBtn.setOnClickListener(new OnClickListener() { @Override/*w ww.j a v a 2 s . c om*/ public void onClick(View v) { finish(); } }); right_img.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { startActivity(new Intent(getBaseContext(), MyRecordActivity.class)); } }); textView = (TextView) findViewById(R.id.title_tv); textView.setText("??"); textView1 = (TextView) findViewById(R.id.cash_textView1); textView2 = (TextView) findViewById(R.id.cash_textView2); textView1.setText("????()"); textView4 = (TextView) findViewById(R.id.cash_textView4); textView5 = (TextView) findViewById(R.id.cash_textView5); textView3 = (TextView) findViewById(R.id.cash_textView6); editText = (EditText) findViewById(R.id.cash_editext1); // ??????? editText.addTextChangedListener(new TextWatcher() { @Override public void afterTextChanged(Editable edt) { String temp = edt.toString(); int posDot = temp.indexOf("."); if (posDot <= 0) return; if (temp.length() - posDot - 1 > 2) { edt.delete(posDot + 3, posDot + 4); } } public void beforeTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) { } public void onTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) { } }); button = (Button) findViewById(R.id.cash_button1); // ??? if (HttpUtils.isNetworkConnected(CashAdvanceActivity.this)) { getData(); } else { Toast.makeText(CashAdvanceActivity.this, Constants.NO_INTENT_TIPS, Toast.LENGTH_LONG).show(); } }
From source file:de.stadtrallye.rallyesoft.fragments.ChatroomFragment.java
@Override public void onClick(View v) { Editable msg = text.getText(); IPictureManager.IPicture pic = pictureHandler.getPicture(); if (pic != null || msg.length() > 0) { chatroom.postChat(msg.toString(), pic); pictureHandler.discardPicture();//TODO wait for postState result... }/*from w w w .j ava 2 s . co m*/ }