performance - How to update the textview content display rapidly in android? -


i want update textview showing current photo number rapidly when long pressed shutter button activate burst shot in camera. know , burst shot in camera, system busy , maybe not refresh textview . have done operations this:

  1. using runnable + handler:
  2. post runnable when current photo number updated
  3. call textview.settext(number) in run()

    private runnable mshowburstnumberrunnable = new runnable() {      public void run() {         mburstshottextview.settext(mcurrentshotsnum);     } }   private picturecallback mcontinuousjpegpicturecallback = new picturecallback() {     public void onpicturetaken(final byte[]data, android.hardware.camera camera) {         ...         mcurrentshotsnum++;         mhandler.post(mshowburstnumberrunnable);         ...     } } 

but textview can't display number rapidly expected. using android 4.2.

you should make sure mhandler posting mshowburstnumberrunnable attached on main thread. main thread change ui.

you try this

private picturecallback mcontinuousjpegpicturecallback = new picturecallback() {     public void onpicturetaken(final byte[]data, android.hardware.camera camera) {         ...         mcurrentshotsnum++;         mburstshottextview.post(mshowburstnumberrunnable);         ...     } } 

Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -