android选择多图存储路径,android 选择本地图片并截剪图片保存到,sdcard指定目录中...

添加上一个 例子:

1、layout 文件 get_p_w_picpaths_view.xml

android:layout_width="fill_parent"

android:layout_height="fill_parent"

android:background="@color/white"

android:gravity="center"

android:orientation="vertical" >

android:id="@+id/showSelectImageId"

android:layout_width="wrap_content"

android:layout_height="wrap_content" />

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:onClick="onclickFun"

android:text="选择图片" />

2、Activity 类

package com.main;

import java.io.File;

import java.util.Calendar;

import android.app.Activity;

import android.content.Intent;

import android.graphics.drawable.Drawable;

import android.net.Uri;

import android.os.Bundle;

import android.view.View;

import android.widget.ImageView;

public class GetImagesActivity extends Activity {

private ImageView p_w_picpathView;

private File tempFile;

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.get_p_w_picpaths_view);

p_w_picpathView = (ImageView) findViewById(R.id.showSelectImageId);

}

public void view) {

Intent innerIntent = new Intent(Intent.ACTION_GET_CONTENT);

innerIntent.putExtra("crop", "true");// 才能出剪辑的小方框,不然没有剪辑功能,只能选取图片

innerIntent.putExtra("aspectX", 1); // 出现放大和缩小

innerIntent.setType("p_w_picpath/*"); // 查看类型 详细的类型在 com.google.android.mms.ContentType

tempFile=new File("/sdcard/ll1x/"+Calendar.getInstance().getTimeInMillis()+".jpg"); // 以时间秒为文件名

File temp = new File("/sdcard/ll1x/");//自已项目 文件夹

if (!temp.exists()) {

temp.mkdir();

}

innerIntent.putExtra("output", Uri.fromFile(tempFile));  // 专入目标文件

innerIntent.putExtra("outputFormat", "JPEG"); //输入文件格式

Intent wrapperIntent = Intent.createChooser(innerIntent, "先择图片"); //开始 并设置标题

startActivityForResult(wrapperIntent, 1); // 设返回 码为 1  onActivityResult 中的 requestCode 对应

}

//调用成功反回方法

@Override

protected void onActivityResult(int requestCode, int resultCode, Intent data) {

super.onActivityResult(requestCode, resultCode, data);

switch (requestCode) {

case 1:

p_w_picpathView.setImageDrawable(Drawable.createFromPath(tempFile.getAbsolutePath()));

break;

}

}

}

3、 AndroidManifest.xml 加上权限

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值