Just swipe over the text to select it and do whatever you want :)
Add jitpack in your root build.gradle at the end of repositories:
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
Add dependency to the module where you want to use it:
dependencies {
implementation 'com.github.rafiksargsyan:EasySelect:v1.1'
}
.......
<com.rsargsyan.easyselect.EasySelectTextView
android:id="@+id/demo"
android:text="Some random text adlkfja ;adkjf a;dljf :)"
app:selectedTextColor="@android:color/holo_green_light"
app:selectedTextHighlightColor="@android:color/transparent"
.......
/>
.......
.......
EasySelectTextView demo = findViewById(R.id.demo);
// Specifies which color must be applied to the selected part of the text
demo.setSelectionTextColor(0x12345678);
// Specifieds which color must be applied to the background of selected text
demo.setSelectionTextHighlightColor(0x87654321);
// Do whatever you want with selected text
demo.setOnSelectionCompletedCallback(selectedString -> {
Toast.makeText(MainActivity.this, selectedString, Toast.LENGTH_SHORT).show();
.......