I want to copy text from TextField
to Clipboard
. My TextField is named txtDetails
and i have a button named btnCopyToClipBoard
.I want to be able to copy the contents of my textfield to clipboard when i press the button.
Name Of InputBox Is "txtDetails" Name Of Button Is "btnCopyToClipBoard"
String StrTemp = txtDetails.getText();
So How We Can Set "OnClickListener" Of "btnCopyToClipBoard" To Copy Value In "StrTemp" To ClipBoard
use global class extends Application for example:
public class G extends Application
And Call In manifiest
and use
public static Context context;
// OnCreate
context = getApplicationContext();
And Then Change That Line As:
ClipboardManager clipboard = (ClipboardManager) G.context.getSystemService(CLIPBOARD_SERVICE);
Or Use
ClipboardManager clipboard = (ClipboardManager) getContext().getSystemService(CLIPBOARD_SERVICE);
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments