TextView
에서 클립 보드로 복사하는 코드가 있지만 android:textIsSelectable="true"
을 추가하지 않으면이 코드가 작동하지 않습니다. 왜? 이 코드를 사용하지 않고 그냥 android:textIsSelectable="true"
을 추가하면 TextView
을 클립 보드로 복사 할 수 있지만 API> = 11 일 때이 코드를 API < 11에 사용할 때 android:textIsSelectable="true"
을 추가하지 않고도 작동 할 것으로 예상되지만, 티. 왜 ???이 간단한 코드가 "android : textIsSelectable ="true ""없이 작동하지 않는 이유는 무엇입니까?
txt=(TextView)findViewById(R.id.txt);
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);
이 질문을 답변없이 보관하려면 내 대답을 수락해야합니다. 나는 당신이 마지막 대답에서 당신이 내가 대답 한 것을 이해했기 때문에 이것을 씁니다. –