我需要为视图的不同百分比值(CircleDisplay)创建X个位图。我总是得到相同的BitMap。如何正确地将不同的视图加载到我的listBitmap?
for(Goal g: goals) {
...
Float percentageValue = (lastTrackDone.getDay_amount()/lastTrack.getDay_forecast()) * 100;
//get goal circle image
cd= (CircleDisplay) parentView.findViewById(R.id.circleDisplay);
cd.setColor(Color.GREEN);
cd.showValue(percentageValue, 100f, true);
cd.getViewTreeObserver().addOnGlobalLayoutListener(
new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
Bitmap bitmap = getBitmapFromView(cd);
listBitmap.add(bitmap);
loadCounter++;
if (numberGoals == loadCounter) {
cd.setVisibility(View.INVISIBLE);
cd.getViewTreeObserver()
.removeOnGlobalLayoutListener(this);
loadGoalsList();
}
}
});
cd.destroyDrawingCache();
cd.setDrawingCacheEnabled(false);
}
最好的问候