Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <EditText
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:editable="false"
- style="?android:attr/textViewStyle"
- android:textColor="@color/white"
- android:textAppearance="@android:style/TextAppearance.Medium"
- android:cursorVisible="false"
- android:background="@null" />
- @Override
- public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
- //user has long pressed your TextView
- menu.add(0, v.getId(), 0, "text that you want to show in the context menu - I use simply Copy");
- //cast the received View to TextView so that you can get its text
- TextView yourTextView = (TextView) v;
- //place your TextView's text in clipboard
- ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
- clipboard.setText(yourTextView.getText());
- }
- <TextView
- android:id="@+id/deviceIdTV"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:textIsSelectable="true"
- android:text="" />
Add Comment
Please, Sign In to add comment