How do I allow pasting into an empty EditText?
The pop-up popup does not appear when I long press on an empty EditText (OK with non-empty).
XML
<EditText
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:gravity="right"
android:textSize="50sp"
android:inputType="numberDecimal"
android:id="@+id/text"/>
Code that concerns EditText
editText.setRawInputType(InputType.TYPE_NULL);
if (Build.VERSION.SDK_INT >= 11) {
editText.setTextIsSelectable(true);
} else {
editText.setFocusable(true);
}
+3
source to share
3 answers
Add this and try again:
android:textIsSelectable="true"
android:cursorVisible="false"
so your layout will contain:
<EditText
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:gravity="right"
android:textSize="50sp"
android:inputType="numberDecimal"
android:id="@+id/text"
android:textIsSelectable="true"
android:cursorVisible="false"/>
if you set android:cursorVisible="true"
so that you can only insert when the field is not empty.
0
source to share
try this code and answer me if it works: D
XML Code
android:inputType="none"
android:textIsSelectable="true"
Java code
textView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
ClipboardManager cm = (ClipboardManager)context.getSystemService(Context.CLIPBOARD_SERVICE);
cm.setText(textView.getText());
Toast.makeText(context, "Copied to clipboard", Toast.LENGTH_SHORT).show();
}
});
0
source to share