From d1a6d13686d796b5f9c737a90ec508c0c4da0c8d Mon Sep 17 00:00:00 2001 From: Asura146 Date: Tue, 19 Dec 2023 13:31:42 +0900 Subject: [PATCH] =?UTF-8?q?=E7=8A=B6=E6=85=8B=E3=81=AB=E3=82=88=E3=81=A3?= =?UTF-8?q?=E3=81=A6=E8=83=8C=E6=99=AF=E8=89=B2=E3=82=92=E5=A4=89=E5=8C=96?= =?UTF-8?q?=E3=81=95=E3=81=9B=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB=E3=81=97?= =?UTF-8?q?=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/example/childguard/HomeFragment.java | 11 +++++++++-- app/src/main/res/drawable/frame_style_orange.xml | 7 +++++++ app/src/main/res/layout/fragment_home.xml | 1 - 3 files changed, 16 insertions(+), 3 deletions(-) create mode 100644 app/src/main/res/drawable/frame_style_orange.xml diff --git a/app/src/main/java/com/example/childguard/HomeFragment.java b/app/src/main/java/com/example/childguard/HomeFragment.java index 7a7d163..09f6885 100644 --- a/app/src/main/java/com/example/childguard/HomeFragment.java +++ b/app/src/main/java/com/example/childguard/HomeFragment.java @@ -1,14 +1,18 @@ package com.example.childguard; import android.content.SharedPreferences; +import android.graphics.Color; +import android.graphics.drawable.Drawable; import android.os.Bundle; +import androidx.core.content.res.ResourcesCompat; import androidx.fragment.app.Fragment; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.widget.FrameLayout; import android.widget.TextView; /** @@ -70,17 +74,20 @@ public class HomeFragment extends Fragment { super.onResume(); Log.d("HomeFragment", "onResume: called"); TextView situationTextView = getView().findViewById(R.id.situation); - updateInCarStatus(situationTextView); + FrameLayout situation_bg=getView().findViewById(R.id.situation_bg); + updateInCarStatus(situationTextView,situation_bg); } - public void updateInCarStatus(TextView situationTextView) { + public void updateInCarStatus(TextView situationTextView,FrameLayout situation_bg) { SharedPreferences sharedPreferences = getActivity().getSharedPreferences("default", 0); Log.d("HomeFragment", "updateInCarStatus: " + sharedPreferences.getBoolean("inCar", false)); if (sharedPreferences.getBoolean("inCar", false)) { situationTextView.setText("\n降車状態"); + situation_bg.setBackground(ResourcesCompat.getDrawable(getResources(), R.drawable.frame_style, null)); } else { situationTextView.setText("\n乗車状態"); + situation_bg.setBackground(ResourcesCompat.getDrawable(getResources(), R.drawable.frame_style_orange, null)); } } } \ No newline at end of file diff --git a/app/src/main/res/drawable/frame_style_orange.xml b/app/src/main/res/drawable/frame_style_orange.xml new file mode 100644 index 0000000..3b4922f --- /dev/null +++ b/app/src/main/res/drawable/frame_style_orange.xml @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_home.xml b/app/src/main/res/layout/fragment_home.xml index 9e29d27..21d6c78 100644 --- a/app/src/main/res/layout/fragment_home.xml +++ b/app/src/main/res/layout/fragment_home.xml @@ -7,7 +7,6 @@ android:layout_height="match_parent" android:orientation="vertical" tools:context=".HomeFragment"> -