Note that there are some explanatory texts on larger screens.

plurals
  1. POImplementing a while loop in android
    primarykey
    data
    text
    <p>I can't understand the implementation of a while loop in android.</p> <p>Whenever I implement a while loop inside the <code>onCreate()</code> bundle, (code shown below)</p> <pre><code>public void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.main); TextView=(TextView)findViewById(R.id.TextView); while (testByte == 0) updateAuto(); } </code></pre> <p>nothing boots up, and the program enters a "hanging" state after a while and I can't understand why. Testbyte is as follows:</p> <pre><code>byte testByte == 0; </code></pre> <p>and <code>updateAuto()</code> is supposed to update the code per 1 second and display inside the textView portion. I've been using setText inside updateAuto() as shown below and everything works fine, but once i implement the while loop all i see is a black screen and then an option to force close after a few seconds due to it "not responding".</p> <pre><code>TextView.setText(updateWords); </code></pre> <p>I've changed it to a button format (meaning i have to click on the button to update itself for now), but i want it to update itself instead of manually clicking it.</p> <p>Am i implementing the while loop in a wrong way?</p> <p>I've also tried calling the while loop in a seperate function but it still gives me the black screen of nothingness.</p> <p>I've been reading something about a Handler service... what does it do? Can the Handler service update my <code>TextView</code> in a safer or memory efficient way?</p> <p>Many thanks if anyone would give some pointers on what i should do on this.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload