在我的代码中,我想使用其字体将文本复制到剪贴板。我所有的代码只是复制文本而不是字体。那么如何从文本框中复制带有字体的文本?
private TextView confetti;
private EditText input;
private ImageButton ctc;
private ClipboardManager myClipboard;
private ClipData myClip;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
myClipboard = (ClipboardManager)getSystemService(CLIPBOARD_SERVICE);
ctc = (ImageButton) findViewById(R.id.copy);
ctc.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String text = input.getText().toString();
myClip = ClipData.newPlainText("text", text);
myClipboard.setPrimaryClip(myClip);
Toast.makeText(getApplicationContext(), "Text Copied",
Toast.LENGTH_SHORT).show();
}});}}