java - Android: How to Use Handlers With Thread Class and UI Thread (MainActivity) -
i viewed answer here: updating android ui using threads
but not able understand how instantiate handler in background thread match uithread.
i want clear , im using 2 entirely separate classes.
uithread handler code:
final handler handler = new handler(){ @override public void handlemessage(message msg) { if(msg.what==update_image){ images.get(msg.arg1).setimagebitmap((bitmap) msg.obj); } super.handlemessage(msg); } };
background thread handler code:
if(dataarrives){ message msg = handler.obtainmessage(); msg.what = update_image; msg.obj = bitmap; msg.arg1 = index; handler.sendmessage(msg); }
in background class, im getting "handler" undefined. please show entire thread classes in answer if can.
Comments
Post a Comment