0

I have in my project buttons of numbers button to dial and one button to delete the char next to the cursor(the insert, the line that blinked when writing text).

if I put the cursor in the middle of the string in the edit text, I need to get the position of the cursor in the text. someone know a method that gives me this information?

I try to use

  int pos = _NumberToCall.getSelectionStart();
  String text = _NumberToCall.getText().toString();

  if (pos == _NumberToCall.getText().toString().length()){
                    _NumberToCall.setText(text.substring(0,text.length()-1));
                }else{

   }
Emad
  • 588
  • 1
  • 9
  • 22

1 Answers1

0
  int pos = _NumberToCall.getSelectionStart();
  String text = _NumberToCall.getText().toString();

  if (pos == _NumberToCall.getText().toString().length()){
       _NumberToCall.setText(text.substring(0,text.length()-1));
  }else{
       _NumberToCall.setText( new StringBuilder(text).deleteCharAt(pos).toString());
  }
yuzuriha
  • 465
  • 1
  • 8
  • 18