diff --git a/students/soft1714080902331/AndroidManifest.xml b/students/soft1714080902331/AndroidManifest.xml
index 814e9d42f..8f71ab49c 100644
--- a/students/soft1714080902331/AndroidManifest.xml
+++ b/students/soft1714080902331/AndroidManifest.xml
@@ -7,8 +7,8 @@
-
+
+
@@ -19,10 +19,7 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
-
+
CUT_PICTURE
+ //onActivityResult()中主要是实现图片裁剪
+ startActivityForResult(intent, CUT_PICTURE);
+ }
+ });
+ chooseFromAlbum.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ File outputImage = new File(Environment.getExternalStorageDirectory(),
+ "output_image.jpg");
+ try {
+ if (outputImage.exists()) {
+ outputImage.delete();
+ }
+ outputImage.createNewFile();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ imageUri = Uri.fromFile(outputImage);
+ Intent intent = new Intent(Intent.ACTION_PICK,null);
+ //此处调用了图片选择器
+ //如果直接写intent.setDataAndType("image/*");
+ //调用的是系统图库
+ intent.setDataAndType(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, "image/*");
+ intent.putExtra(MediaStore.EXTRA_OUTPUT, imageUri);
+ startActivityForResult(intent, CUT_PICTURE);
+ }
+ });
}
-}
->>>>>>> 04de59006bcef14253116cac674bc33ccca7169d
+
+ @Override
+ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
+ switch (requestCode) {
+ case CUT_PICTURE:
+ if (resultCode == RESULT_OK) {
+ //此处启动裁剪程序
+ Intent intent = new Intent("com.android.camera.action.CROP");
+ //此处注释掉的部分是针对android 4.4路径修改的一个测试
+ //有兴趣的读者可以自己调试看看
+// String text=data.getData().toString();
+// Toast.makeText(MainActivity.this, text, Toast.LENGTH_SHORT).show();
+ intent.setDataAndType(data.getData(), "image/*");
+ intent.putExtra("scale", true);
+ intent.putExtra(MediaStore.EXTRA_OUTPUT, imageUri);
+ startActivityForResult(intent, SHOW_PICTURE);
+ }
+ break;
+ case SHOW_PICTURE:
+ if (resultCode == RESULT_OK) {
+ try {
+ //将output_image.jpg对象解析成Bitmap对象,然后设置到ImageView中显示出来
+ Bitmap bitmap = BitmapFactory.decodeStream(getContentResolver().openInputStream(imageUri));
+ picture.setImageBitmap(bitmap);
+ } catch (FileNotFoundException e) {
+ e.printStackTrace();
+ }
+ }
+ break;
+ default:
+ break;
+ }
+ }
+
+
+
+
+
+}
\ No newline at end of file
diff --git a/students/soft1714080902331/Soft1714080902331Activity4.java b/students/soft1714080902331/Soft1714080902331Activity4.java
deleted file mode 100644
index dcfaba102..000000000
--- a/students/soft1714080902331/Soft1714080902331Activity4.java
+++ /dev/null
@@ -1,133 +0,0 @@
-package edu.hzuapps.androidlabs.soft1714080902331;
-
-import android.content.Intent;
-import android.graphics.Bitmap;
-import android.graphics.BitmapFactory;
-import android.net.Uri;
-import android.os.Bundle;
-import android.os.Environment;
-import android.provider.MediaStore;
-import android.support.v7.app.AppCompatActivity;
-import android.view.View;
-import android.widget.Button;
-import android.widget.ImageView;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-
-public class Soft1714080902331Activity4 extends AppCompatActivity {
-
- public static final int CUT_PICTURE = 1;
-
- public static final int SHOW_PICTURE = 2;
-
- private Button takePhoto;
-
- private Button chooseFromAlbum;
-
- private ImageView picture;
-
- private Uri imageUri;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.soft_1714080902331_activity4);
- takePhoto = (Button) findViewById(R.id.take_photo);
- chooseFromAlbum = (Button) findViewById(R.id.choose_from_album);
- picture = (ImageView) findViewById(R.id.picture);
-
- takePhoto.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- //创建File对象,用于存储拍照后的图片
- //将此图片存储于SD卡的根目录下
- File outputImage = new File(Environment.getExternalStorageDirectory(),
- "output_image.jpg");
- try {
- if (outputImage.exists()) {
- outputImage.delete();
- }
- outputImage.createNewFile();
- } catch (IOException e) {
- e.printStackTrace();
- }
- //将File对象转换成Uri对象
- //Uri表标识着图片的地址
- imageUri = Uri.fromFile(outputImage);
- //隐式调用照相机程序
- Intent intent = new Intent("android.media.action.IMAGE_CAPTURE");
- //拍下的照片会被输出到output_image.jpg中去
- intent.putExtra(MediaStore.EXTRA_OUTPUT, imageUri);
- //此处是使用的startActivityForResult()
- //因此在拍照完后悔有结果返回到onActivityResult()中去,返回值即为CUT_PICTURE
- //onActivityResult()中主要是实现图片裁剪
- startActivityForResult(intent, CUT_PICTURE);
- }
- });
-
- chooseFromAlbum.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- File outputImage = new File(Environment.getExternalStorageDirectory(),
- "output_image.jpg");
- try {
- if (outputImage.exists()) {
- outputImage.delete();
- }
- outputImage.createNewFile();
- } catch (IOException e) {
- e.printStackTrace();
- }
- imageUri = Uri.fromFile(outputImage);
- Intent intent = new Intent(Intent.ACTION_PICK,null);
- //此处调用了图片选择器
- //如果直接写intent.setDataAndType("image/*");
- //调用的是系统图库
- intent.setDataAndType(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, "image/*");
- intent.putExtra(MediaStore.EXTRA_OUTPUT, imageUri);
- startActivityForResult(intent, CUT_PICTURE);
- }
- });
- }
-
-
- @Override
- protected void onActivityResult(int requestCode, int resultCode, Intent data) {
- switch (requestCode) {
- case CUT_PICTURE:
- if (resultCode == RESULT_OK) {
- //此处启动裁剪程序
- Intent intent = new Intent("com.android.camera.action.CROP");
- //此处注释掉的部分是针对android 4.4路径修改的一个测试
- //有兴趣的读者可以自己调试看看
-// String text=data.getData().toString();
-// Toast.makeText(MainActivity.this, text, Toast.LENGTH_SHORT).show();
- intent.setDataAndType(data.getData(), "image/*");
- intent.putExtra("scale", true);
- intent.putExtra(MediaStore.EXTRA_OUTPUT, imageUri);
- startActivityForResult(intent, SHOW_PICTURE);
- }
- break;
- case SHOW_PICTURE:
- if (resultCode == RESULT_OK) {
- try {
- //将output_image.jpg对象解析成Bitmap对象,然后设置到ImageView中显示出来
- Bitmap bitmap = BitmapFactory.decodeStream(getContentResolver().openInputStream(imageUri));
- picture.setImageBitmap(bitmap);
- } catch (FileNotFoundException e) {
- e.printStackTrace();
- }
- }
- break;
- default:
- break;
- }
- }
-
-
-
-
-
-}
\ No newline at end of file
diff --git a/students/soft1714080902331/soft_1714080902331_activity.xml b/students/soft1714080902331/soft_1714080902331_activity.xml
index 3bf3dac80..91d2fe136 100644
--- a/students/soft1714080902331/soft_1714080902331_activity.xml
+++ b/students/soft1714080902331/soft_1714080902331_activity.xml
@@ -37,16 +37,10 @@
android:layout_marginTop="80dp"
app:srcCompat="@android:drawable/ic_menu_edit" />
-
+
-
-
-
-
-
-=======
-
-
-
-
-
-
+
+
-
-
-
-
-
-
-
-
-
->>>>>>> 04de59006bcef14253116cac674bc33ccca7169d
+ android:layout_height="wrap_content"
+ android:background="@android:color/background_light"
+ android:gravity="center"
+ android:text="点击下方按钮用图片记录事物吧!"
+ android:textAlignment="center"
+ android:textSize="20sp" />
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/students/soft1714080902331/soft_1714080902331_activity4.xml b/students/soft1714080902331/soft_1714080902331_activity4.xml
deleted file mode 100644
index d1fda8ddd..000000000
--- a/students/soft1714080902331/soft_1714080902331_activity4.xml
+++ /dev/null
@@ -1,43 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file