Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9004799
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:58:53+00:00 2026-06-16T00:58:53+00:00

I know you can only change the text in tTxtViews from the UI thread

  • 0

I know you can only change the text in tTxtViews from the UI thread but i cant seem to find a way to work with that.

I’ll go in to a bit more details: I’m trying to have a TextView that displays the time passed, but I can’t do it in a thread, or a method that keeps getting called.
can you help me with a way of doing this? because I’m pretty much out of ideas.

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T00:58:54+00:00Added an answer on June 16, 2026 at 12:58 am
            public class MainActivity extends Activity {
    
                protected static final long TIMER_DELAY = 100;
                private TextView tv;
                protected Handler handler;
    
                @Override
                protected void onCreate(Bundle savedInstanceState) {
                    super.onCreate(savedInstanceState);
                    setContentView(R.layout.activity_main);
    
                    tv = (TextView)findViewById(R.id.helloWorld);
                    handler = new Handler();
                    handler.post(timerTask);
    
    
                }
    
                private Runnable timerTask = new Runnable() {
                    public void run() {
                        Calendar now = Calendar.getInstance();
    
                        //format date time
                        tv.setText(String.format("%02d:%02d:%02d", now.get(Calendar.HOUR_OF_DAY), now.get(Calendar.MINUTE), now.get(Calendar.SECOND)));
    
                        //run again with delay
                        handler.postDelayed(timerTask, TIMER_DELAY);
                    }
                };
    
    
            }
    

    I forgot add this, sorry. Don’t forget do this:

    @Override
        public void onPause() {
    
            if (handler != null)
                handler.removeCallbacks(timerTask);
    
            super.onPause();
    }
    

    And if you want resume app try this

    @Override
        public void onResume() {
            super.onResume();
    
            if (handler != null)
                handler.post(timerTask);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know that ScrollView can have only one Child but in my case I
I know that a view can only be a subview of one superview, so
I have a query that I know can be done using a subselect, but
I know I can override paint to change the text color in a labelfield,
I have a problem with NSTextField - that I can't change the text in
I know that when using a EditText we can change the input type using
Hi i want to get changed text value from JQuery but i can't select
I know it can't be done since using var can only be done for
I know we can't compare 2 floating point values using ==. We can only
I want to know how can i fill only certain columns while filling the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.