Android之线程回掉更新ui
一:工作线程中的回掉更新UI public class MainActivity extends AppCompatActivity { private int i; private Callback mCallback; private TextView textView; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); textView = (TextView) findViewById(R.id.text); mCallback = new Callback() { @Override public void callback(int i) { textView.setText("i"); } }; doWorkAsNewThread(5000,mCallback); } /** * 开启工作线程 * @param delayMs 延时,以便对比 * @param callback 回掉,更新Ui */ private void doWorkAsNewThread(final long delayMs, final Callback callback