android - Cannot change UI in runOnUiThread -


i want change textview content result of calculation in thread, crashing when execution. here's code.

new thread(new runnable() {         public void run() {             while (i < 5) {                i++;             }             getactivity().runonuithread(new runnable() {                 public void run() {                     textview txv = (textview) getview().findviewbyid(r.id.txvone);                     log.d("123","i = "+ i);                     txv.settext(i);//crash!!!                 }             });         } }).start(); 

enter image description here

you need pass string type settext() method. when pass integer type, performs lookup r(see : r) file string resource specified id. since id not match item in strings.xml file, exception thrown resourcenotfoundexception.

like sree said, try code below, guaranteed work.

txv.settext(string.valueof(i))); 

Comments

Popular posts from this blog

sql - VB.NET Operand type clash: date is incompatible with int error -

SVG stroke-linecap doesn't work for circles in Firefox? -

python - TypeError: Scalar value for argument 'color' is not numeric in openCV -