Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2020
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. public class ThreadHelper {
  2.  
  3. private TextView textView;
  4.  
  5. public ThreadHelper(TextView textView) {
  6. this.textView = textView;
  7. }
  8.  
  9. public void runOnAnotherThread() {
  10. Thread thread = new Thread(new Runnable() {
  11. @Override
  12. public void run() {
  13. textView.post(new Runnable() {
  14. @Override
  15. public void run() {
  16. textView.setText("FirstText");
  17. }
  18. });
  19. }
  20. });
  21. thread.start();
  22. }
  23.  
  24. public void addText(final String text){
  25. textView.post(new Runnable() {
  26. @Override
  27. public void run() {
  28. textView.setText(textView.getText() + "\n" + text);
  29. }
  30. });
  31. }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement