보기를 기반으로 n 개의 이미지를 동적으로 만들려고합니다.
LayoutInflater infalter=(LayoutInflater)getApplicationContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
final View addview=infalter.inflate(R.layout.barcode_image_list_row_item, null);
final ImageView imv=(ImageView) addview.findViewById(R.id.imageView1);
final TextView tv=(TextView) addview.findViewById(R.id.textView1);
try {
final Bitmap bitmap = encodeAsBitmap(""+value, BarcodeFormat.CODE_128, 600, 300);
if (bitmap != null) {
// TODO Auto-generated method stub
imv.setImageBitmap(bitmap);
tv.setText(value);
addview.setDrawingCacheEnabled(true);
// this is the important code :)
// Without it the view will have a dimension of 0,0 and the bitmap will be null
addview.measure(MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED),
MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
addview.layout(0, 0, addview.getMeasuredWidth(), addview.getMeasuredHeight());
addview.buildDrawingCache(true);
Bitmap b = Bitmap.createBitmap(addview.getDrawingCache());
addview.setDrawingCacheEnabled(false); // clear drawing cache
// saving the bitmap
savebarcode(b,value);
}
} catch (WriterException e) {
e.printStackTrace();
}
이 코드가 누군가에게 도움이 될 것 같아요 ..
getDrawingCache()
사용View#draw
하는Canvas
방법