如何将文本从EditText
复制到剪贴板中,并设置字体?
参见以下代码
btnz.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String name =et.getText().toString();
Typeface myfont=Typeface.createFromAsset(getAssets(), "ComialUnicoder.ttf");
tv.setText(name);
tv.setTypeface(myfont);
}
});
btncopy.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
String font = tv.getTypeface().toString();
ClipData clip = ClipData.newPlainText("label", font);
clipboard.setPrimaryClip(clip);