I have a class which extends RelativeLayout
and in this class I create a Thread
. My custom RelativeLayout
is now used in a ListView
.
Now my problem. I start the Thread
after instantiation of my class. Now the user scrolled the ListView
very fast. Where can I stop my Thread
, because if my custom RelativeLayout
is out of scope it won't be GC
ed because the Thread
is still there.
Here a stub of my code...
private Thread mThread;
public class MyLayout() extends RelativeLayout {
public MyLayout(Context context) {
super(context);
mThread = new Thread(new Runnable...);
mThread.start();
}
}
如果在每个列表项中都使用了视图,则在传递给getView()的视图为非null时,可以在适配器中停止线程,这意味着线程将被回收。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.