Guest User

Untitled

a guest
Jul 16th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. <EditText
  2. android:layout_width="fill_parent"
  3. android:layout_height="wrap_content"
  4. android:editable="false"
  5. style="?android:attr/textViewStyle"
  6. android:textColor="@color/white"
  7. android:textAppearance="@android:style/TextAppearance.Medium"
  8. android:cursorVisible="false"
  9. android:background="@null" />
  10.  
  11. @Override
  12. public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
  13. //user has long pressed your TextView
  14. menu.add(0, v.getId(), 0, "text that you want to show in the context menu - I use simply Copy");
  15.  
  16. //cast the received View to TextView so that you can get its text
  17. TextView yourTextView = (TextView) v;
  18.  
  19. //place your TextView's text in clipboard
  20. ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
  21. clipboard.setText(yourTextView.getText());
  22. }
  23.  
  24. <TextView
  25. android:id="@+id/deviceIdTV"
  26. android:layout_width="wrap_content"
  27. android:layout_height="wrap_content"
  28. android:textIsSelectable="true"
  29. android:text="" />
Add Comment
Please, Sign In to add comment