国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 系統 > Android > 正文

Android 實現IOS選擇拍照相冊底部彈出的實例

2019-12-12 02:23:15
字體:
來源:轉載
供稿:網友

Android 實現IOS選擇拍照相冊底部彈出的實例

效果圖

1. AndroidStudio使用

dependencies {  compile 'com.guoqi.widget:actionsheet:1.0'}

2. 使用

//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);}

感謝閱讀,希望能幫助到大家,謝謝大家對本站的支持,如有疑問請留言或者到本站社區交流討論,大家共同進步!

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 兴文县| 克什克腾旗| 宁强县| 十堰市| 永寿县| 台湾省| 秦皇岛市| 抚松县| 赣州市| 南充市| 新巴尔虎右旗| 巫溪县| 得荣县| 钟祥市| 玛纳斯县| 通城县| 博湖县| 合水县| 德安县| 巴林左旗| 永胜县| 汉阴县| 苍溪县| 依兰县| 厦门市| 米脂县| 渑池县| 宝丰县| 上杭县| 奉贤区| 娱乐| 东海县| 揭东县| 察隅县| 阳西县| 金寨县| 马山县| 乃东县| 昌邑市| 荥阳市| 周宁县|