Android “Only the original thread that created a view hierarchy can touch its views.” error in for loop
<p>I am trying to run the for loop in every half second.The loop is changing something in the view every time it is called,but the changes are made by another class i.e Speedometer.</p>

<pre><code>Thread thread=new Thread(){
        @Override
        public void run() {
            float i;
            try {

                for ( i = 0; i &lt;= 100; i++) {
                            Speedometer1.onSpeedChanged(Speedometer1.getCurrentSpeed(i) + 8);
                            Speedometer2.onSpeedChanged(Speedometer2.getCurrentSpeed(i) + 8);
                            Speedometer3.onSpeedChanged(Speedometer3.getCurrentSpeed(i) + 8);
                            Speedometer4.onSpeedChanged(Speedometer4.getCurrentSpeed(i) + 8);
                            Speedometer5.onSpeedChanged(Speedometer5.getCurrentSpeed(i) + 8);
                            Speedometer6.onSpeedChanged(Speedometer6.getCurrentSpeed(i) + 8);


                    sleep(500);
                }
            }
            catch (InterruptedException e)
            {e.printStackTrace();}
        }
    };thread.start();
</code></pre>