Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6654859
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T01:26:29+00:00 2026-05-26T01:26:29+00:00

My code is : EditText edt edt.addTextChangedListener(new TextWatcher() { @Override public void afterTextChanged(Editable arg0)

  • 0

My code is :

EditText edt
    
edt.addTextChangedListener(new TextWatcher() {
    
    @Override
    public void afterTextChanged(Editable arg0) {
    
        final String number = edt.getText().toString();
    
        int count = arg0.length();
        edt.setSelection(count);
    }
    
    @Override
    public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        // TODO Auto-generated method stub
    }
    
    @Override
    public void onTextChanged(CharSequence s, int start, int before, int count) {
        final String number = edt.getText().toString();
    }
}

I have a dialpad too. When I click a particular number in the dial pad, I need to add that number to the current cursor position. Also, when I press delete, I need to delete the number from the current cursor position.

Dialpad Image

enter image description here

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T01:26:30+00:00Added an answer on May 26, 2026 at 1:26 am

    Try the following code

    int start =editText.getSelectionStart(); //this is to get the the cursor position
    String s = "Some string";
    editText.getText().insert(start, s); //this will get the text and insert the String s into   the current position
    

    Here is the code to delete selected text from EditText

    int start = t1.getSelectionStart();  //getting cursor starting position
    int end = t1.getSelectionEnd();      //getting cursor ending position
    String selectedStr = t1.getText().toString().substring(start, end);    //getting the selected Text
    t1.setText(t1.getText().toString().replace(selectedStr, ""));    //replacing the selected text with empty String and setting it to EditText
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My code: final EditText et1 = (EditText)findViewById(R.id.et1); et1.setOnFocusChangeListener(new OnFocusChangeListener(){ @Override public void onFocusChange(View v,
I have the following code: SharedPreferences KITPrefs; EditText passPhraseExample; ... @Override public void onCreate(Bundle
I have an EditText and a TextWatcher. Skeleton of my code: EditText x; x.addTextChangedListener(new
with this code, my program just force close(error) ***public View x = findViewById(R.string.nfoname);*** @Override
Code below does not run correctly and throws InvalidOperationExcepiton . public void Foo() {
findViewById returns null for EditText Java Code: public class MainActivity extends Activity { private
Ok, I'm using the code: EditText editText = (EditText) findViewById(R.id.editText1); String value = editText.getText().toString();
I have those code: public class ContentEditText extends EditText { /* * Constructors */
A piece of code to update DB raw: private EditText et; //... private void
In edittext, after typing 'Enter' key, system make a new line inside it. I'd

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.