java - Function without final argument, which includes Runnable() -


how create function without final argument, includes runnable()?

 public void scroll(int scroll_to) {         final horizontalscrollview scrl = (horizontalscrollview)findviewbyid(r.id.horizontalscrollview1);         scrl.post(new runnable() {              public void run() {                   scrl.scrollto(0, scroll_to);             }          });     } 

but cannot refer non-final scroll_to variable. how universal function scroll? without runnable not work.

how this?

public void scroll(int scroll_to) {     final int x = scroll_to;     final horizontalscrollview scrl = (horizontalscrollview)findviewbyid(r.id.horizontalscrollview1);     scrl.post(new runnable()     {         public void run()         {             scrl.scrollto(0, x);         }      }); } 

Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -