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

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

routes - Laravel 4 Wildcard Routing to Different Controllers -

cross browser - XSLT namespace-alias Not Working in Firefox or Chrome -