In one touch i want to get a option to select and copy the text from textview like the image show here.
Just Set "textIsSelectable" on the TextView to true
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Detail Text"
android:id="@+id/txtBody"
android:background="@android:color/white"
android:gravity="right"
android:textColor="@android:color/black"
android:textSize="16sp"
android:padding="5dp"
android:enabled="true"
android:textIsSelectable="true"/>
In your onClickListener for the TextView:
ClipboardManager clipboard =
(ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
clipboard.setText(yourTextView.getText());
ed
: Answer to the question in comments :
yourTextView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO: add your code here
}
});
just add this to your TextView
xml file :
android:textIsSelectable="true"