How to get selected text from edittext in android?

I have a edittext in which some text are selected . I want to get only selected text from edittext on click of button .

Please suggest me usable link or sample code.

  • Inside Eclipse Android project run Java classes with main(String args) as Java Application causes “Invalid layout of java.lang.String at value”
  • Xamarin Android Player / Visual Studio: Stuck at “Starting Emulator”
  • ActionBarSherlock + maven + eclipse: dependency not found in workspace
  • Listview items Animation Stop While Scrolling
  • Android Studio: “SDK installation does not have the ”Extras > Android Support Repository“ installed” BUT IT HAS BEEN INSTALLED
  • Implementation of FCM with XMPP using Smack for Android
  • Related posts:

    Center a button in a Linear layout
    How i can optimize this code that contain some repetitive line?
    Detect When other Application opened or Launched
    Issues with Translucent Theme
    No resource found that matches the given name: attr 'android:actionModeShareDrawable&#0...
    Weird behavior of CrossWalk-based hybrid app when playing m4a web audio
  • Should I restore savedinstancestate in onCreate or in onRestoreInstanceState?
  • SQLite Foreign Key
  • Create 3D animtation for Android Apps
  • Get size of Bitmap Android
  • Android - getTargetFragment and setTargetFragment - What are they used for
  • Why is onStop being called right after my Activity is launched?
  • 2 Solutions collect form web for “How to get selected text from edittext in android?”

    EditText et=(EditText)findViewById(;
    int startSelection=et.getSelectionStart();
    int endSelection=et.getSelectionEnd();
    String selectedText = et.getText().toString().substring(startSelection, endSelection);

    see this link

    Android Babe is a Google Android Fan, All about Android Phones, Android Wear, Android Dev and Android Games Apps and so on.