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

  • SEARCH
  • Home
  • 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 3842052
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T15:44:19+00:00 2026-05-19T15:44:19+00:00

Okay, I was able to figure out a timer earlier, but now I’m having

  • 0

Okay, I was able to figure out a timer earlier, but now I’m having another problem

So, when I call this function called “getNextQuote();” the first time in onCreate() it updates and gets a random quote and displays it perfectly, however, when I try again, in onResume(), it doesn’t refresh for some reason.

public void getNextQuote(){

    TextView tv = (TextView) findViewById(R.id.quote);//Text To be edited
    Random QuoteNum = new Random();     

    int Quote = QuoteNum.nextInt(50);

    android.util.Log.i("DebugB",""+Quote);

    String q = myString[Quote];//find which string is corresponding to the number
    tv.setText(q);//Set the Text 

    android.util.Log.i("DebugC",q);
}

anything obvious I’m missing???
In the log the new quotes are coming out like there supposed to, but they just arn’t getting drawn to the actual emulator screen.

  • 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-05-19T15:44:20+00:00Added an answer on May 19, 2026 at 3:44 pm

    try this:

    int i = 0;
    
    public void getNextQuote(){
    
    runOnUiThread(new Runnable() {
    
        @Override
        public void run() {
            TextView tv = (TextView) findViewById(R.id.quote);//Text To be edited
            tv.setText("test"+i);//Set the Text
            i++;
        }
    });
    

    }

    This counts test0, test1, test2,… 🙂 Just put your code into that runOnUiThread. When I tried your code, I got an error (because of the thread). Also check, if your interval is short enough. Just try 1000 msec. 🙂

    UPDATE:

    Maybe this is a better aproach by reusing the Runnable (don’t really know) 🙂

    int i = 0;
    
    Runnable updateTextView = new Runnable() {
    
        @Override
        public void run() {
            TextView tv = (TextView) findViewById(R.id.text_view);//Text To be edited
            tv.setText("test"+i);//Set the Text
            i++;
        }
    };
    
    public void getNextQuote(){
    
        runOnUiThread(updateTextView);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Okay, I thought I would be able to do this no problem, but for
Okay, this should be painfully obvious, however I haven't been able to figure out
Okay, I feel a bit foolish for having to ask this but I guess
Okay, I've tried to figure this out over and over again. I know the
Okay, this should be a fairly easy question I think, but haven't been able
Having an odd problem with a MySQL query, I can't really figure out how
Okay, I feel like I should be able to do this, but I have
Okay, here goes. Stack Overflow virgin here but hopefully you guys will be able
A while ago I was trying to figure out a way of doing this
I haven't been able to figure out how to deal with a specific regex

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.