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();
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
Post a Comment