我將圖像添加到一個gridview,一切完美,直到我將手機橫置,在GridView即消失的所有圖像,並在日誌圖像轉向手機端的方式
SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero length
出現此錯誤時消失
我用我的GridView中獲取圖像通過手機的相機這樣
Intent camera_intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(camera_intent, CAMERA_PIC_REQUEST);
後,我打電話圖像適配器
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
switch(requestCode){
case 0:
if(resultCode==RESULT_OK){
Bitmap thumbnail = (Bitmap) data.getExtras().get("data");
Bitmap.createScaledBitmap(thumbnail, 100, 100, true);
Drawable drawable = new BitmapDrawable(getResources(), thumbnail);
list.add(drawable);
GridView gv = (GridView)findViewById(R.id.GridV1);
gv.setAdapter(new ImageAdapter(this, list));
}
}
}
最後這是我在ImageAdapter
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ImageView imageView;
if (convertView == null) {
imageView = new ImageView(mContext);
imageView.setLayoutParams(new GridView.LayoutParams(130, 130));
imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
imageView.setPadding(10, 10, 10, 10);
} else {
imageView = (ImageView) convertView;
}
imageView.setImageDrawable(mThumbIds.get(position));
return imageView;
}
我認爲這是與規模增加我的圖片,但我不知道,也無法找到解決這個問題。
非常感謝這些教程。肯定會檢查出來,這將是非常有用的未來項目:) – Oscar