我已經發送文本這段代碼是從第一的TextView選擇第二的TextView與點擊一個按鈕:如何在此代碼中使用「getCharSequence」?
txt=(TextView)findViewById(R.id.txt);
txt2=(TextView)findViewById(R.id.txt2);
btn=(Button)findViewById(R.id.btn);
final int startIndex = txt.getSelectionStart();
final int endIndex = txt.getSelectionEnd();
final String stringYouExtracted = txt.getText().toString().substring(startIndex, endIndex);
ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
clipboard.setText(stringYouExtracted);
btn.setOnClickListener(new OnClickListener() {
public void onClick(View arg0) {
txt2.setText(stringYouExtracted);
}
});
但是當我按下按鈕沒有任何發送到TXT2和TXT2是空的....爲什麼? ?
我認爲txt2.setText(stringYouExtracted)
是錯的,但我非常biginner,我無法修復它?
是否公開CharSequence getCharSequence (String key)
解決方案?如果是的話,幫助我,因爲我不知道如何使用它?
正是你想要做什麼? – InnocentKiller
我想在第一個textview中選擇,然後clipboard_service將enabe ......並且我有另一個textview ,,,,,所以用戶有兩個選項.....第一個選擇剪貼板....第二個新聞該按鈕,並從他的第二個文本視圖 – Ehsan