文件名称:android图片拍照 删除 添加 旋转
文件大小:456KB
文件格式:RAR
更新时间:2015-06-11 11:14:36
android /图片 /删/ 添加 /旋转
android 图片 拍照 删除 添加 旋转 @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.image_show); path = Environment.getExternalStorageDirectory(); file = new File(path + "/MapGIS/myImg/"); file.mkdirs(); getSD(); mSwitcher = (ImageSwitcher) findViewById(R.id.switcher); gallery = (Gallery) findViewById(R.id.gallery); mSwitcher.setFactory(this); mSwitcher.setInAnimation(AnimationUtils.loadAnimation(this, android.R.anim.fade_in)); mSwitcher.setInAnimation(AnimationUtils.loadAnimation(this, android.R.anim.fade_out)); gallery.setAdapter(new ImageAdapter(this)); gallery.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { public void onItemSelected(AdapterView<?> adapter, View view, int position, long id) { mSwitcher.setImageURI(imgList1.get(position).getUri()); pos = position; } public void onNothingSelected(AdapterView<?> arg0) { } }); // 拍照按钮 Button paizhao = (Button) this.findViewById(R.id.paizhao); paizhao.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { // 判断SD卡是不是能用 if (isAvaiableSpace(600)) { // 当前可用 Intent imgIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmmss"); Date date = new Date(); nameTmp = dateFormat.format(date); imgIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(new File(file, nameTmp + ".jpg"))); startActivityForResult(imgIntent, 1); } else // 当前不可用 { Toast.makeText(PhotoShowActivity.this, "SD卡不可用!", Toast.LENGTH_SHORT).show(); } } }); // 删除按钮 Button shanchu = (Button) this.findViewById(R.id.shanchu); shanchu.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { // TODO Auto-generated method stub if (!imgList1.isEmpty()) { // 存放图片名字 final String fname = imgList1.get(pos).getName(); new AlertDialog.Builder(PhotoShowActivity.this).setIcon(R.drawable.alert_dialog_icon) .setTitle("警告").setMessage("确认删除此图片?") .setPositiveButton("确定", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { // TODO Auto-generated method stub File SDPATH2 = Environment.getExternalStorageDirectory(); File file2 = new File(SDPATH2 + "/MapGIS/myImg/" + fname); file2.delete(); imgList1.remove(pos); gallery.setAdapter(new ImageAdapter(PhotoShowActivity.this)); mSwitcher.reset(); Toast.makeText(PhotoShowActivity.this, "图片已成功删除!", Toast.LENGTH_SHORT).show(); } }).setNegativeButton("取消", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { Toast.makeText(PhotoShowActivity.this, "你取消了删除图片!", Toast.LENGTH_SHORT).show(); } }).show(); } else { Toast.makeText(PhotoShowActivity.this, "当前没有图片可以删除", Toast.LENGTH_SHORT).show(); } } }); // 向左旋转图片按钮 xuanzhuan2 = (Button) this.findViewById(R.id.xuanzhuan2); xuanzhuan2.setOnClickListener(new MyXuanZhuanClick(270)); // 向右旋转图片按钮 xuanzhuan = (Button) this.findViewById(R.id.xuanzhuan); xuanzhuan.setOnClickListener(new MyXuanZhuanClick(90)); }
【文件预览】:
PhotoShow
----AndroidManifest.xml(1KB)
----res()
--------layout()
--------drawable-ldpi()
--------drawable()
--------drawable-mdpi()
--------drawable-hdpi()
--------drawable-xhdpi()
--------values()
----src()
--------com()
----proguard-project.txt(781B)
----bin()
--------classes()
--------PhotoShow16.apk(47KB)
--------PhotoShow23.apk(49KB)
--------PhotoShow21.apk(48KB)
--------res()
--------classes.dex(18KB)
--------PhotoShow17.apk(47KB)
--------PhotoShow18.apk(48KB)
--------PhotoShow22.apk(48KB)
--------resources.ap_(38KB)
--------PhotoShow20.apk(48KB)
----.classpath(374B)
----assets()
----project.properties(562B)
----.project(847B)
----gen()
--------com()