Notice
Recent Posts
Recent Comments
Link
«   2024/10   »
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31
Archives
Today
Total
관리 메뉴

쨍쨍

AI 심리 분석 프로그램 본문

프로그래밍 코드/Android Studio

AI 심리 분석 프로그램

이선선 2024. 7. 22. 17:34

 

[ activity_main.xml ]

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:background="@color/yellow1"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context=".EnterActivity">
    <LinearLayout
        android:layout_marginTop="30dp"
        android:layout_marginLeft="30dp"
        android:layout_width="350dp"
        android:layout_height="580dp"
        android:background="@drawable/ground"
        android:orientation="vertical">

        <TextView
            android:id="@+id/name1"
            android:layout_width="match_parent"
            android:layout_height="40dp"
            android:gravity="center"
            android:hint="그림으로 알아보는 나의 심리 상태"
            android:textSize="20dp"
            android:textStyle="bold"
            android:textColor="#FF000000"
            android:layout_marginTop="100dp"/>

    <TextView
        android:id="@+id/name2"
        android:layout_width="match_parent"
        android:layout_height="55dp"
        android:gravity="center"
        android:hint="도담이"
        android:textSize="40dp"
        android:textStyle="bold"
        android:textColor="#FF000000" />

    <ImageView
        android:layout_width="match_parent"
        android:layout_height="150dp"
        android:layout_marginTop="30dp"
        android:src="@drawable/dodami2" />

    <Button
        android:id="@+id/enterButton"
        android:layout_width="150dp"
        android:layout_height="70dp"
        android:layout_marginTop="30dp"
        android:gravity="center"
        android:background="@drawable/button_1"
        android:layout_marginStart="100dp"
        android:textSize="20dp"
        android:text="시작하기" />

    </LinearLayout>

    <TextView
        android:id="@+id/nam"
        android:layout_width="match_parent"
        android:layout_height="40dp"
        android:gravity="center"
        android:hint="※ 정확한 검사 및 진단은 전문가와의 상담이 필요합니다."
        android:textSize="15dp"
        android:textStyle="bold"
        android:textColor="#DEE2E6"
        android:layout_marginTop="5dp"/>
</LinearLayout>

 

 

[ EnterActivity ]

package com.example.dodami;

import android.content.Intent;
import android.os.Bundle;
import android.widget.Button;
import androidx.appcompat.app.AppCompatActivity;

public class EnterActivity extends AppCompatActivity {
    private Button startButton;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        startButton = findViewById(R.id.enterButton);

        startButton.setOnClickListener(v -> {
            Intent intent = new Intent(EnterActivity.this, SettingActivity.class);
            startActivity(intent);
        });
    }
}

 

 

 

 

[ activity_setting ]

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:background="@color/yellow1"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context=".SettingActivity">
    <LinearLayout
        android:layout_marginTop="30dp"
        android:layout_marginLeft="30dp"
        android:layout_width="350dp"
        android:layout_height="600dp"
        android:background="@drawable/ground"
        android:orientation="vertical">

        <TextView
            android:id="@+id/setting1"
            android:layout_width="match_parent"
            android:layout_height="40dp"
            android:text="사용자님의 연령과 성별을"
            android:layout_marginTop="100dp"
            android:gravity="center"
            android:textColor="#FF000000"
            android:textStyle="bold"
            android:textSize="25dp" />

        <TextView
            android:id="@+id/setting2"
            android:layout_width="match_parent"
            android:layout_height="40dp"
            android:gravity="center"
            android:text="입력해주세요."
            android:textColor="#FF000000"
            android:textStyle="bold"
            android:textSize="25dp" />

        <LinearLayout
            android:layout_marginTop="100dp"
            android:layout_width="match_parent"
            android:layout_height="50dp"
            android:background="@color/white"
            android:orientation="horizontal">

            <TextView
                android:id="@+id/setting3"
                android:layout_marginLeft="70dp"
                android:layout_width="100dp"
                android:layout_height="40dp"
                android:gravity="center"
                android:text="나이 :"
                android:textColor="#FF000000"
                android:textStyle="bold"
                android:textSize="22dp" />

            <EditText
                android:id="@+id/setting4"
                android:layout_width="100dp"
                android:layout_height="wrap_content"
                android:text=""
                android:textColor="#FF000000" />

    </LinearLayout>

        <RadioGroup
            android:layout_width="200dp"
            android:layout_height="wrap_content"
            android:id="@+id/genderGroup"
            android:layout_gravity="center_horizontal"
            android:orientation="horizontal"
            android:layout_marginTop="10dp">

            <RadioButton
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:text="여성"
                android:textSize="22dp"

                android:id="@+id/genderWoman"
                android:layout_weight="1"
                android:checked="true"/>

            <RadioButton
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:text="남성"
                android:textSize="22dp"
                android:id="@+id/genderMan"
                android:layout_weight="1"/>

        </RadioGroup>


        <Button
            android:id="@+id/enterButton"
            android:layout_width="140dp"
            android:layout_height="50dp"
            android:layout_marginStart="100dp"
            android:layout_marginTop="50dp"
            android:background="@drawable/button_1"
            android:gravity="center"
            android:textSize="20dp"
            android:text="ENTER" />

    </LinearLayout>

</LinearLayout>

 

 

[ SettingActivity ]

package com.example.dodami;

import android.content.Intent;
import android.os.Bundle;
import android.widget.Button;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;

public class SettingActivity extends AppCompatActivity {

    private EditText ageEditText;
    private RadioGroup genderGroup;
    private RadioButton selectedGenderButton;
    private Button enterButton;
    private TextView setting1, setting2, setting3;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_setting);

        // XML 레이아웃 요소들 초기화
        ageEditText = findViewById(R.id.setting4);
        genderGroup = findViewById(R.id.genderGroup);
        enterButton = findViewById(R.id.enterButton);
        setting1 = findViewById(R.id.setting1);
        setting2 = findViewById(R.id.setting2);
        setting3 = findViewById(R.id.setting3);

        enterButton.setOnClickListener(v -> {
            String age = ageEditText.getText().toString();
            int selectedGenderId = genderGroup.getCheckedRadioButtonId();
            selectedGenderButton = findViewById(selectedGenderId);

            if (age.isEmpty()) {
                Toast.makeText(SettingActivity.this, "나이를 입력해주세요.", Toast.LENGTH_SHORT).show();
                return;
            }

            String gender = selectedGenderButton.getText().toString();
            Toast.makeText(SettingActivity.this, "나이: " + age + " 세" + "\n성별: " + gender, Toast.LENGTH_SHORT).show();

            // ChooseActivity로 전환
            Intent intent = new Intent(SettingActivity.this, ChooseActivity.class);
            startActivity(intent);
        });
    }
}

 

 

 

 

[ activity_choose ]

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:background="@color/yellow1"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context=".EnterActivity">
    <LinearLayout
        android:layout_marginTop="30dp"
        android:layout_marginLeft="30dp"
        android:layout_width="350dp"
        android:layout_height="600dp"
        android:background="@drawable/ground"
        android:orientation="vertical">

        <TextView
            android:id="@+id/title1"
            android:layout_width="match_parent"
            android:layout_height="40dp"
            android:text="HTP 검사를 시작합니다."
            android:layout_marginTop="100dp"
            android:gravity="center"
            android:textColor="#FF000000"
            android:textStyle="bold"
            android:textSize="28dp" />

        <TextView
            android:id="@+id/text1"
            android:layout_width="match_parent"
            android:layout_height="40dp"
            android:text="HTP 검사는 검사자에게 집, 나무, 사람을"
            android:gravity="center"
            android:layout_marginTop="80dp"
            android:textColor="#FF000000"
            android:textSize="15dp" />

        <TextView
            android:id="@+id/text3"
            android:layout_width="match_parent"
            android:layout_height="40dp"
            android:text="차례로 그리게 한 뒤 그림 해석을 통해 검사자의"
            android:gravity="center"
            android:textColor="#FF000000"
            android:textSize="15dp" />

        <TextView
            android:id="@+id/text2"
            android:layout_width="match_parent"
            android:layout_height="40dp"
            android:text="심리상태를 분석합니다."
            android:gravity="center"
            android:textColor="#FF000000"
            android:textSize="15dp" />

        <Button
            android:id="@+id/startButton"
            android:layout_width="150dp"
            android:layout_height="70dp"
            android:layout_marginTop="80dp"
            android:gravity="center"
            android:background="@drawable/button_1"
            android:layout_marginStart="100dp"
            android:textSize="20dp"
            android:text="시작하기" />

    </LinearLayout>
</LinearLayout>

 

 

[ ChooseActivity ]

package com.example.dodami;

import android.os.Bundle;
import androidx.appcompat.app.AppCompatActivity;


import android.content.Intent;
import android.view.View;
import android.widget.Button;

public class ChooseActivity extends AppCompatActivity {

        private Button start_Button;
    private View startButton;

    @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_choose);

            startButton = findViewById(R.id.startButton);

            startButton.setOnClickListener(v -> {
                Intent intent = new Intent(ChooseActivity.this, HouseActivity.class);
                startActivity(intent);
            });

        }
    }

 

 

 

 

[ activity_house ]

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:background="@color/yellow1"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context=".SettingActivity">
    <LinearLayout
        android:layout_marginTop="30dp"
        android:layout_marginLeft="30dp"
        android:layout_width="350dp"
        android:layout_height="600dp"
        android:background="@drawable/ground"
        android:orientation="vertical">

        <TextView
            android:id="@+id/title1"
            android:layout_width="match_parent"
            android:layout_height="40dp"
            android:text="집을 그려서 이미지 파일로"
            android:layout_marginTop="100dp"
            android:gravity="center"
            android:textColor="#FF000000"
            android:textStyle="bold"
            android:textSize="22dp" />

        <TextView
            android:id="@+id/title2"
            android:layout_width="match_parent"
            android:layout_height="40dp"
            android:gravity="center"
            android:text="첨부해 주세요."
            android:textColor="#FF000000"
            android:textStyle="bold"
            android:textSize="22dp" />

        <ImageView
            android:id="@+id/imageView"
            android:layout_width="match_parent"
            android:layout_height="200dp"
            android:layout_marginTop="16dp"
            android:contentDescription="Selected Image" />

        <Button
            android:id="@+id/selectImageButton"
            android:layout_width="150dp"
            android:layout_height="60dp"
            android:layout_marginTop="20dp"
            android:gravity="center"
            android:background="@drawable/button_1"
            android:layout_marginStart="100dp"
            android:textSize="20dp"
            android:text="사진 선택" />


        <Button
            android:id="@+id/enterButton"
            android:layout_width="150dp"
            android:layout_height="60dp"
            android:layout_marginTop="20dp"
            android:gravity="center"
            android:background="@drawable/button_1"
            android:layout_marginStart="100dp"
            android:textSize="20dp"
            android:text="다음" />
    </LinearLayout>
</LinearLayout>

 

 

[ HouseActivity ]

package com.example.dodami;


import android.Manifest;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Bundle;
import android.provider.MediaStore;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.Toast;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;

public class HouseActivity extends AppCompatActivity {

    private static final int REQUEST_CODE_READ_STORAGE = 1;
    private static final int PICK_IMAGE_REQUEST = 2;
    private ImageView imageView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_house);

        imageView = findViewById(R.id.imageView);

        Button selectImageButton = findViewById(R.id.selectImageButton);
        selectImageButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                requestStoragePermission();
            }
        });

        Button enterButton = findViewById(R.id.enterButton);
        enterButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                // TreeActivity로 이동
                Intent intent = new Intent(HouseActivity.this, TreeActivity.class);
                startActivity(intent);
            }
        });
    }

    private void requestStoragePermission() {
        if (ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
            ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, REQUEST_CODE_READ_STORAGE);
        } else {
            openGallery();
        }
    }

    @Override
    public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
        super.onRequestPermissionsResult(requestCode, permissions, grantResults);
        if (requestCode == REQUEST_CODE_READ_STORAGE) {
            if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
                openGallery();
            } else {
                Toast.makeText(this, "저장소 접근 권한이 필요합니다.", Toast.LENGTH_SHORT).show();
            }
        }
    }

    private void openGallery() {
        Intent intent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
        startActivityForResult(intent, PICK_IMAGE_REQUEST);
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (requestCode == PICK_IMAGE_REQUEST && resultCode == RESULT_OK && data != null) {
            Uri selectedImageUri = data.getData();
            if (selectedImageUri != null) {
                imageView.setImageURI(selectedImageUri); // 선택된 이미지를 이미지뷰에 표시
            }
        }
    }
}

 

 

 

 

 

[ activity_tree ]

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:background="@color/yellow1"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context=".SettingActivity">
    <LinearLayout
        android:layout_marginTop="30dp"
        android:layout_marginLeft="30dp"
        android:layout_width="350dp"
        android:layout_height="600dp"
        android:background="@drawable/ground"
        android:orientation="vertical">

        <TextView
            android:id="@+id/title1"
            android:layout_width="match_parent"
            android:layout_height="40dp"
            android:text="나무를 그려서 이미지 파일로"
            android:layout_marginTop="100dp"
            android:gravity="center"
            android:textColor="#FF000000"
            android:textStyle="bold"
            android:textSize="22dp" />

        <TextView
            android:id="@+id/title2"
            android:layout_width="match_parent"
            android:layout_height="40dp"
            android:gravity="center"
            android:text="첨부해 주세요."
            android:textColor="#FF000000"
            android:textStyle="bold"
            android:textSize="22dp" />

        <ImageView
            android:id="@+id/imageView"
            android:layout_width="match_parent"
            android:layout_height="200dp"
            android:layout_marginTop="16dp"
            android:contentDescription="Selected Image" />

        <Button
            android:id="@+id/selectImageButton"
            android:layout_width="150dp"
            android:layout_height="60dp"
            android:layout_marginTop="20dp"
            android:gravity="center"
            android:background="@drawable/button_1"
            android:layout_marginStart="100dp"
            android:textSize="20dp"
            android:text="사진 선택" />


        <Button
            android:id="@+id/enterButton"
            android:layout_width="150dp"
            android:layout_height="60dp"
            android:layout_marginTop="20dp"
            android:gravity="center"
            android:background="@drawable/button_1"
            android:layout_marginStart="100dp"
            android:textSize="20dp"
            android:text="다음" />
    </LinearLayout>
</LinearLayout>

 

 

[ TreeActivity ]

package com.example.dodami;

import android.Manifest;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Bundle;
import android.provider.MediaStore;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.Toast;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;

public class TreeActivity extends AppCompatActivity {

    private static final int REQUEST_CODE_READ_STORAGE = 1;
    private static final int PICK_IMAGE_REQUEST = 2;
    private ImageView imageView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_tree);

        imageView = findViewById(R.id.imageView);

        Button selectImageButton = findViewById(R.id.selectImageButton);
        selectImageButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                requestStoragePermission();
            }
        });

        Button enterButton = findViewById(R.id.enterButton);
        enterButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                // PeopleActivity로 이동
                Intent intent = new Intent(TreeActivity.this, PeopleActivity.class);
                startActivity(intent);
            }
        });
    }

    private void requestStoragePermission() {
        if (ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
            ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, REQUEST_CODE_READ_STORAGE);
        } else {
            openGallery();
        }
    }

    @Override
    public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
        super.onRequestPermissionsResult(requestCode, permissions, grantResults);
        if (requestCode == REQUEST_CODE_READ_STORAGE) {
            if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
                openGallery();
            } else {
                Toast.makeText(this, "저장소 접근 권한이 필요합니다.", Toast.LENGTH_SHORT).show();
            }
        }
    }

    private void openGallery() {
        Intent intent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
        startActivityForResult(intent, PICK_IMAGE_REQUEST);
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (requestCode == PICK_IMAGE_REQUEST && resultCode == RESULT_OK && data != null) {
            Uri selectedImageUri = data.getData();
            if (selectedImageUri != null) {
                imageView.setImageURI(selectedImageUri); // 선택된 이미지를 이미지뷰에 표시
            }
        }
    }
}

 

 

 

 

 

[ activitiy_people ]

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:background="@color/yellow1"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context=".SettingActivity">
    <LinearLayout
        android:layout_marginTop="30dp"
        android:layout_marginLeft="30dp"
        android:layout_width="350dp"
        android:layout_height="600dp"
        android:background="@drawable/ground"
        android:orientation="vertical">

        <TextView
            android:id="@+id/title1"
            android:layout_width="match_parent"
            android:layout_height="40dp"
            android:text="사람을 그려서 이미지 파일로"
            android:layout_marginTop="100dp"
            android:gravity="center"
            android:textColor="#FF000000"
            android:textStyle="bold"
            android:textSize="22dp" />

        <TextView
            android:id="@+id/title2"
            android:layout_width="match_parent"
            android:layout_height="40dp"
            android:gravity="center"
            android:text="첨부해 주세요."
            android:textColor="#FF000000"
            android:textStyle="bold"
            android:textSize="22dp" />

        <ImageView
            android:id="@+id/imageView"
            android:layout_width="match_parent"
            android:layout_height="200dp"
            android:layout_marginTop="16dp"
            android:contentDescription="Selected Image" />

        <Button
            android:id="@+id/selectImageButton"
            android:layout_width="150dp"
            android:layout_height="60dp"
            android:layout_marginTop="20dp"
            android:gravity="center"
            android:background="@drawable/button_1"
            android:layout_marginStart="100dp"
            android:textSize="20dp"
            android:text="사진 선택" />


        <Button
            android:id="@+id/enterButton"
            android:layout_width="150dp"
            android:layout_height="60dp"
            android:layout_marginTop="20dp"
            android:gravity="center"
            android:background="@drawable/button_1"
            android:layout_marginStart="100dp"
            android:textSize="20dp"
            android:text="다음" />
    </LinearLayout>
</LinearLayout>

 

 

[ PeopleActivity ]

package com.example.dodami;

import android.Manifest;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Bundle;
import android.provider.MediaStore;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.Toast;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;

public class PeopleActivity extends AppCompatActivity {

    private static final int REQUEST_CODE_READ_STORAGE = 1;
    private static final int PICK_IMAGE_REQUEST = 2;
    private ImageView imageView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_people);

        imageView = findViewById(R.id.imageView);

        Button selectImageButton = findViewById(R.id.selectImageButton);
        selectImageButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                requestStoragePermission();
            }
        });

        Button enterButton = findViewById(R.id.enterButton);
        enterButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                // TreeActivity로 이동
                Intent intent = new Intent(PeopleActivity.this, ResultActivity.class);
                startActivity(intent);
            }
        });
    }

    private void requestStoragePermission() {
        if (ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
            ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, REQUEST_CODE_READ_STORAGE);
        } else {
            openGallery();
        }
    }

    @Override
    public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
        super.onRequestPermissionsResult(requestCode, permissions, grantResults);
        if (requestCode == REQUEST_CODE_READ_STORAGE) {
            if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
                openGallery();
            } else {
                Toast.makeText(this, "저장소 접근 권한이 필요합니다.", Toast.LENGTH_SHORT).show();
            }
        }
    }

    private void openGallery() {
        Intent intent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
        startActivityForResult(intent, PICK_IMAGE_REQUEST);
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (requestCode == PICK_IMAGE_REQUEST && resultCode == RESULT_OK && data != null) {
            Uri selectedImageUri = data.getData();
            if (selectedImageUri != null) {
                imageView.setImageURI(selectedImageUri); // 선택된 이미지를 이미지뷰에 표시
            }
        }
    }
}