java - TextView will not update from a loop in Android -
I have a simple app that updates a TextView
with values generated in a loop When I click on a button
But when I run the app, it only shows the last number in the TextView
. I added Thread.sleep ()
to slow the loop but it does not work, yet what is wrong with me here? Thanks in advance
public class mainstred actionbusiness activity (button btnshow; textview txtSee; @ override protected minus creatives (bundle saved instenstate) {super. Knight (saved instenstate); setContentView (R.layout.activity_main_thread); BtnShow = (button) findViewById (R.id.btnShow); TxtSee = (TextView) Find ViewById (R.id.txtSee); BtnShow.setOnClickListener (new OnClickListener) {@Override Public void onClick (see v) {try (for int i = 0; i & lt; = 5; i ++) {string lesson 1 = "no change" + i + "" "; TxtSee . SetText (text1); thread (2000);}} Catch (Interrupted Expression E) {}}});} ....}
>
txtSee.setText (text1);
Your loop is performing very fast so that you can see the changes
Comments
Post a Comment