如何将文本复制到剪切板中的Andr​​oid?如何将、文本、剪切板、oid

由网友(Mephistophelian 魔鬼)分享简介:谁能告诉我如何复制文本present在一个特定的TextView到剪贴板当按钮是pressed?感谢名单:)Can anybody please tell me how to copy the text present in a particular textview to clipboard when a but...

谁能告诉我如何复制文本present在一个特定的TextView到剪贴板当按钮是pressed? 感谢名单:)

Can anybody please tell me how to copy the text present in a particular textview to clipboard when a button is pressed? Thanx :)

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.mainpage);
    textView = (TextView) findViewById(R.id.textview);
    copyText = (Button) findViewById(R.id.bCopy);
    copyText.setOnClickListener(new View.OnClickListener() {


        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub

            ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
            String getstring = textView.getText().toString();

            //Help to continue :)





        }
    });
}

}

我要复制的文本中的TextView TextView中到剪贴板时,按钮BCOPY是pressed!请你帮助...

I want to copy the Text in TextView textView to clipboard when the Button bCopy is pressed! Please do help...

推荐答案

使用ClipboardManager

 ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE); 
 ClipData clip = ClipData.newPlainText(label, text);
 clipboard.setPrimaryClip(clip);

检查该link

阅读全文

相关推荐

最新文章