I’m developing an android app, but I’m a little confused about making a decision between EditText and TextView since I can do the following for both:
android:textIsSelectable=”true”
android:editable=”false”
android:inputType=”none”
android:cursorVisible=“false”
My goal is to let the user to have the options “copy” and “share” the text. The sharing feature did not appear in EditText nor TextView by default!! Also, making TextView selectable did not work in earlier versions of android that are below 4.0.
So, I need the user to copy and share the text in all android versions, How? Thanks for any help
If you want the user to be able to change the text, use an EditText or if you only want the user to select the text for copying & pasting, use a TextView. You won’t find any single attribute for sharing. However:
This guide will walk you through using the clipboard to: Copy & Paste
And read this guide on Adding an Easy Share Action
Both are from the Android Developers and provide a wealth of information.
As for being able to select text in a TextView, you don’t need any special attributes. Simply long press any word in the text. The XML below is all you need:
However, feel free to add more attributes to give it style and personality.