WEB开发网
开发学院手机开发Android 开发 android listView 子控件事件错行处理 阅读

android listView 子控件事件错行处理

 2012-11-16 15:34:01 来源:WEB开发网   
核心提示:File picture = Communal.getInstance().getPhotoName();if(picture != null)startPhotoZoom(Uri.fromFile(picture));}if (data == null)return;// 读取相册缩放图片if (requestCod
File picture = Communal.getInstance().getPhotoName();
if(picture != null)
startPhotoZoom(Uri.fromFile(picture));
}

if (data == null)
return;

// 读取相册缩放图片
if (requestCode == PHOTOZOOM) {
startPhotoZoom(data.getData());
}
// 处理结果
if (requestCode == PHOTORESOULT) {
Bundle extras = data.getExtras();
if (extras != null) {
Bitmap photo = null;
try {
photo = extras.getParcelable("data");
if(photo == null)
return;
ByteArrayOutputStream stream = new ByteArrayOutputStream();
photo.compress(Bitmap.CompressFormat.JPEG, 75, stream);// (0 - 100)压缩文件
stream.flush();
stream.close();
} catch (IOException e) {
// TODO Auto-generated catch block
String log1 = "打印时间:" + Communal.getInstance().getFormatDate("") + "PatrolAdapter异常:" + e.getMessage();
LogFile.getInstance().addLog(log1);
e.printStackTrace();
}

HashMap<String, Object> map = new HashMap<String, Object>();
map.put("ItemImage", photo);//添加图像资源的ID
map.put("ItemText", Communal.getInstance().getImageName());//按序号做ItemText
imageItem.add(map);
if(holderDatas.size() > index)
{
holderDatas.get(index).setImageList(imageItem);
}
initGridViewImage();
initPicture(Communal.getInstance().getImageName());
}


}


}

public void startPhotoZoom(Uri uri) {
Intent intent = new Intent("com.android.camera.action.CROP");
intent.setDataAndType(uri, IMAGE_UNSPECIFIED);
intent.putExtra("crop", "true");
// aspectX aspectY 是宽高的比例
intent.putExtra("aspectX", 1);
intent.putExtra("aspectY", 1);
// outputX outputY 是裁剪图片宽高
intent.putExtra("outputX", 64);
intent.putExtra("outputY", 64);
intent.putExtra("return-data", true);
activity.startActivityForResult(intent, PHOTORESOULT);
}

private void initGridViewImage()
{
ImageAdapter adapter = new ImageAdapter(imageItem,context);
photograph.setAdapter(adapter);
photograph.setOnItemClickListener(pictureView_ItemClickListener);
}

GridView.OnItemClickListener pictureView_ItemClickListener = new GridView.OnItemClickListener(){


@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
long arg3) {
// TODO Auto-generated method stub
//在本例中arg2=arg3
Intent intent = null;
HashMap<String, Object> item=(HashMap<String, Object>) arg0.getItemAtPosition(arg2);
String text = (String)item.get("ItemText");
intent = new Intent(context,PictureViewActivity.class);
intent.putExtra("pictureName", text);
context.startActivity(intent);

}};

GridView.OnItemLongClickListener pictureView_ItemLongClickListener = new GridView.OnItemLongClickListener(){

上一页  3 4 5 6 7 8 9 10  下一页

Tags:android listView 控件

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接