EditText setSelection - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for EditText setSelection method.

This code example shows how to use the following methods:setSelection, getSelectionEnd, getSelectionStart, setTransformationMethod
    toggleShowPassphrase(passphrase, isChecked);
    toggleShowPassphrase(confirm, isChecked);
  } 
 
  private void toggleShowPassphrase(EditText field, boolean isChecked) {
    int start=field.getSelectionStart();
    int end=field.getSelectionEnd();
 
    if (isChecked) {
      field.setTransformationMethod(null);
    } 
    else { 
      field.setTransformationMethod(new PasswordTransformationMethod());
    } 
 
    field.setSelection(start, end);
  } 
 
  @Override 
  public void onClick(View v) {
    v.setEnabled(false);
8
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:setSelection, getSelectionEnd, getSelectionStart, setTransformationMethod
                                                   .toString());
  } 
 
  @Override 
  public void onCheckedChanged(CompoundButton cb, boolean isChecked) {
    int start=passphrase.getSelectionStart();
    int end=passphrase.getSelectionEnd();
 
    if (isChecked) {
      passphrase.setTransformationMethod(null);
    } 
    else { 
      passphrase.setTransformationMethod(new PasswordTransformationMethod());
    } 
 
    passphrase.setSelection(start, end);
  } 
 
  void populate(int id, String _title, String _passphrase) {
    this.id=id;
    title.setText(_title);
8
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:setSelection, setText
This code example shows how to use the following methods:getText, setSelection
		return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,
				val, ctx.getResources().getDisplayMetrics());
	} 
 
	public static void putCursorAfterLastSymbol(EditText editText) {
		editText.setSelection(editText.getText().length());
	} 
 
	public static void showKeyboard(final View view) {
		new Handler(Looper.getMainLooper()).postDelayed(new Runnable() {
 
			@Override 
			public void run() { 
				setKeyboardVisible(view, true);
			} 
		}, 200); 
	} 
 
	public static void setKeyboardVisible(View view, boolean visible) {
		InputMethodManager imm = (InputMethodManager) view.getContext()
7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getText, setSelection, setText
        /* If we don't have displayed values then use the 
         * current number else find the correct value in the 
         * displayed values for the current number. 
         */ 
        if (mDisplayedValues == null) {
            mText.setText(formatNumber(mCurrent));
        } else { 
            mText.setText(mDisplayedValues[mCurrent - mStart]);
        } 
        mText.setSelection(mText.getText().length());
    } 
 
    private void validateCurrentView(CharSequence str) {
        int val = getSelectedPos(str.toString());
        if ((val >= mStart) && (val <= mEnd)) {
            if (mCurrent != val) {
                mPrevious = mCurrent;
                mCurrent = val;
                notifyChange(); 
            } 
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getText, setSelection, setText
        return (EditText) getCurrentView();
    } 
         
    Editable getText() {
        EditText text = (EditText) getCurrentView();
        return text.getText();
    } 
     
    void setText(CharSequence text, Scroll dir) {
        if (getText().length() == 0) {
            dir = Scroll.NONE;
        } 
         
        if (dir == Scroll.UP) {
            setInAnimation(inAnimUp);
            setOutAnimation(outAnimUp);            
        } else if (dir == Scroll.DOWN) {
            setInAnimation(inAnimDown);
            setOutAnimation(outAnimDown);            
        } else { // Scroll.NONE 

6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:setSelection, setText
        super.onResume(); 
 
        SharedPreferences prefs = getPreferences(0); 
        String restoredText = prefs.getString("text", null);
        if (restoredText != null) {
            mSaved.setText(restoredText, TextView.BufferType.EDITABLE);
 
            int selectionStart = prefs.getInt("selection-start", -1);
            int selectionEnd = prefs.getInt("selection-end", -1);
            if (selectionStart != -1 && selectionEnd != -1) {
                mSaved.setSelection(selectionStart, selectionEnd);
            } 
        } 
    } 
 
    /** 
     * Any time we are paused we need to save away the current state, so it 
     * will be restored correctly when we are resumed. 
     */ 
    @Override 
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getText, setSelection, setText
        /* If we don't have displayed values then use the 
         * current number else find the correct value in the 
         * displayed values for the current number. 
         */ 
        if (mDisplayedValues == null) {
            mText.setText(formatNumber(mCurrent));
        } else { 
            mText.setText(mDisplayedValues[mCurrent - mStart]);
        } 
        mText.setSelection(mText.getText().length());
    } 
 
    private void validateCurrentView(CharSequence str) {
        int val = getSelectedPos(str.toString());
        if ((val >= mStart) && (val <= mEnd)) {
            if (mCurrent != val) {
                mPrevious = mCurrent;
                mCurrent = val;
                notifyChange(); 
            } 
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getText, setSelection, setText
        // TODO Auto-generated method stub 
    } 
 
    public void setText(String name, String text) {
        mOnTextChangedListenerEnabled = false;
        if ((text != null) && !text.equals(mEditText.getText().toString())) {
            mEditText.setText(text);
            mEditText.setSelection(text.length());
        } 
        mOnTextChangedListenerEnabled = true;
    } 
 
    public void setTextVisibility(boolean visible) {
        // TODO Auto-generated method stub 
    } 
 
    public void setVideo(String name, Uri video) {
        try { 
            Bitmap bitmap = VideoAttachmentView.createVideoThumbnail(mContext, video);
            if (null == bitmap) {
7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getText, setSelection, getSelectionStart, setText
        /* If we don't have displayed values then use the 
         * current number else find the correct value in the 
         * displayed values for the current number. 
         */ 
        if (mDisplayedValues == null) {
            int curSelectedPos = mText.getSelectionStart();
            int curTextLength = mText.getText().length();
             
            mText.setText(formatNumber(mCurrent));
             
            /* Preserve previous cursor position (right justified) */ 
            selectPos = mText.getText().length();
            selectPos -= (curTextLength - Math.max(curSelectedPos, 0));
            selectPos = Math.max(selectPos, 0);
        } else { 
            mText.setText(mDisplayedValues[mCurrent - mStart]);
            selectPos = mText.getText().length();
        } 
        mText.setSelection(selectPos);
    } 

7
CodeRank
Experience pair programming with AI  Get Codota for Java

Related EditText setSelection Questions & Answers:

setSelection Method Overview
Convenience for setSelection(Spannable, int).
See Code Examples for other Android EditText Methods: