Button to copy the value of a string to the clipboard

后端 未结 2 439
别跟我提以往
别跟我提以往 2021-02-09 15:01

I\'m modifying an old Android application. I have a GPS lat and long being stored in a string value and displayed to the user in a non-editable text box when it resolves. I wa

2条回答
  •  北海茫月
    2021-02-09 15:15

    If it is just Text, it is very simple.

    ClipboardManager clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
    ClipData clip = ClipData.newPlainText("label","Your Text");
    clipboard.setPrimaryClip(clip);
    

    For further Information check out this link

提交回复
热议问题