-1
有什麼方法可以在圖庫組件中插入位圖圖像嗎?如何在圖庫組件中添加圖像位圖?
有什麼方法可以在圖庫組件中插入位圖圖像嗎?如何在圖庫組件中添加圖像位圖?
當然,剛剛創建與位圖在您的畫廊適配器返回一個ImageView的
public class MyActivity extends Activity {
final List<Bitmap> bitmaps = new ArrayList<Bitmap>();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
final Gallery galleryV = (Gallery) findViewById(R.id.gallery);
galleryV.setAdapter(new BaseAdapter() {
@Override
public int getCount() {
return bitmaps.size();
}
@Override
public Object getItem(int position) {
return bitmaps.get(position);
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(final int position, View convertView, final ViewGroup parent) {
if (convertView == null) {
convertView = new ImageView(MyActivity.this);
}
((ImageView) convertView).setImageBitmap(bitmaps.get(position));
return convertView;
}
});
}
}