2012-08-29 40 views
-1

這是我的代碼:複製文本從TextView的

Button copy; 
Button previous; 
Button more; 
TextView screen; 
String quote=screen.getText().toString(); 

我需要的按鈕,抄來抄去的變量quote的價值。我怎樣才能做到這一點?我試過了:

ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE); 
clipboard.setText(screen.getText()); 

但它只適用於Android 4.0及更高版本的設備。

+0

如何接受>> –

+0

爲什麼所有的人評論之前否決:((( –

+0

現在看到的編輯問題!!!! –

回答

2

我認爲你的進口是錯誤的。

使用

import android.text.ClipboardManager ; 

,而不是

import android.content.ClipboardManager; // this was instroduced only in API level 11 
+0

eclipe在說「The ClipboardMana ger已棄用「 –

+0

是的,它已被您嘗試使用的content.clipboardmanager棄用。如果你想在Gingerbread和下面的設備中使用clipboardmanager,那麼你將不得不使用已棄用的類 – nandeesh

+0

我必須同時導入 import android.content.ClipboardManager; &import android.text.ClipboardManager; –