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 8778489
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T19:33:05+00:00 2026-06-13T19:33:05+00:00

I want to run a classic flood fill algorithm that has a visual representation

  • 0

I want to run a classic flood fill algorithm that has a visual representation of how the algorithm progresses; i.e a series of buttons that turn black to show the sequence of the algorithm. I don’t want to cheat by producing an iterative version of the recursive algorithm. P
oorly tabbed pseudocode ahead:

public void floodFill(int x, int y, String targetColor,String replacementColor) {
            if *out of bounds* return
              else
               if button = target then return
                else
                 Switchbuttontoblack(button);
                 PAUSE;
         floodFill(x - 1, y, targetColor, replacementColor);
         floodFill(x + 1, y, targetColor, replacementColor);
         floodFill(x, y - 1, targetColor, replacementColor);
         floodFill(x, y + 1, targetColor, replacementColor);
}

But, although the algorithm executes there buttons only change colour all at once at the end of the algorithm.

This might be due to be a non UI thread as in Android timer updating a textview (UI).

Therefore I implemented a runnable at the PAUSE line of the algoithm (i.e
handler.post(runnable);

where runnable is

private Runnable runnable = new Runnable() {
       public void run() {

            Log.d("RUNableworking","RUNableworking");
            handler.postDelayed(this, 1000);

       }
    };

Running from the Floodfill thread = nothing. Running from onCreate I see the log just fine.

I’m not too keen on polling the runnable; there must be a better way of doing this?

  • 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-13T19:33:07+00:00Added an answer on June 13, 2026 at 7:33 pm

    There’s a command in Activity called runOnUiThread(), which comes in quite handy. The only problem is that the UI running is queued. You also might be able to use Handler objects to send the UI update calls to the UI thread.

    However, if you are going step-by-step, do you really need to use another thread?

    Update: are you doing the flood fill in the onDraw()? If so, it won’t go step-by-step

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an Exel 2007 PivotTable using classic layout that has 2 row fields.
I am writing an NUnit test that I want run only in the Release
I have a classic ASP application I want to run on my website (IIS7).
I have a web app in classic ASP that most run at all times.
I want run a jquery code that if number value text input was under
I want run all script from the directory . Like , The directory contains
I want run a script as follows: runner: ssh 'java program &' ssh 'java
Why this code don't work,when i want run this code vwd 2008 express show
I have written php program and uploaded on server. I want run this program
Want to run javascript function from parent window in child window Example I have

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.