dependencies {
compile 'com.guoqi.widget:actionsheet:1.0'
}
//1.实现接口
implements ActionSheet.OnActionSheetSelected
//2.在某个点击事件中添加:
ActionSheet.showSheet(this, this, null);
//3.然后重写点击方法:
@Override
public void onClick(int whichButton) {
switch (whichButton) {
case ActionSheet.CHOOSE_PICTURE:
//相册
choosePic();
break;
case ActionSheet.TAKE_PICTURE:
//拍照
takePic();
break;
case ActionSheet.CANCEL:
//取消
break;
}
}
//加入自己的逻辑
public void takePic(){
String state = Environment.getExternalStorageState();
if (state.equals(Environment.MEDIA_MOUNTED)) {
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
File outDir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES);
if (!outDir.exists()) {
outDir.mkdirs();
}
File outFile = new File(outDir, System.currentTimeMillis() + ".jpg");
picPath = outFile.getAbsolutePath();
intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(outFile));
intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1);
startActivityForResult(intent, ActionSheet.TAKE_PICTURE);
} else {
Toast.makeText(this, "请确认已经插入SD卡", Toast.LENGTH_SHORT).show();
}
}
//加入自己的逻辑
public void choosePic(){
Intent openAlbumIntent = new Intent(Intent.ACTION_PICK);
openAlbumIntent.setDataAndType(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, "image/*");
startActivityForResult(openAlbumIntent, ActionSheet.CHOOSE_PICTURE);
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有