在用sidemenu時,參考其demo,在fragment裡開分線程:
@Override
public void takeScreenShot() {
Thread thread = new Thread() {
@Override
public void run() {
Bitmap bitmap = Bitmap.createBitmap(containerView.getWidth(),
containerView.getHeight(), Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
containerView.draw(canvas);
ContentFragment.this.bitmap = bitmap;
}
};
thread.start();
}
這樣做在剛開始並沒有報錯,但是在其中一個fragment裡添加RecyclerView後,在
sidemenu打開時報錯:Only the original thread that created a view hierarchy can touch its views,求解
只有創建這個視圖的原始線程才能接觸到這個視圖