From 51c34966bc06dfd7660d88163c02a3149d1f1852 Mon Sep 17 00:00:00 2001 From: it232115 Date: Tue, 16 Jan 2024 10:56:09 +0900 Subject: [PATCH] =?UTF-8?q?=E3=83=97=E3=83=AA=E3=83=B3=E3=82=BF=E3=83=BC?= =?UTF-8?q?=E7=94=BB=E9=9D=A2=E3=81=8B=E3=82=89=E6=88=BB=E3=81=A3=E3=81=9F?= =?UTF-8?q?=E6=99=82=E3=81=AB=E7=94=BB=E9=9D=A2=E3=81=8C=E7=99=BD=E4=B8=80?= =?UTF-8?q?=E8=89=B2=E3=81=AB=E3=81=AA=E3=82=8B=E3=83=90=E3=82=B0=E3=82=92?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E3=81=97=E3=81=BE=E3=81=97=E3=81=9F=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/example/childguard/QrPrintFragment.java | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/example/childguard/QrPrintFragment.java b/app/src/main/java/com/example/childguard/QrPrintFragment.java index 21c7646..bdae229 100644 --- a/app/src/main/java/com/example/childguard/QrPrintFragment.java +++ b/app/src/main/java/com/example/childguard/QrPrintFragment.java @@ -9,6 +9,8 @@ import android.graphics.drawable.BitmapDrawable; import android.os.Bundle; import androidx.fragment.app.Fragment; +import androidx.fragment.app.FragmentManager; +import androidx.fragment.app.FragmentTransaction; import androidx.print.PrintHelper; import android.preference.PreferenceManager; @@ -132,7 +134,20 @@ public class QrPrintFragment extends Fragment { printHelper.setColorMode(PrintHelper.COLOR_MODE_COLOR); printHelper.setScaleMode(PrintHelper.SCALE_MODE_FIT); printHelper.printBitmap("job_name", QRGazou); - + HomeFragment homeFragment=new HomeFragment(); + replaceFragment(homeFragment); return view; } + private void replaceFragment(Fragment fragment) { + // フラグメントマネージャーの取得 + FragmentManager manager = getParentFragmentManager(); // アクティビティではgetSupportFragmentManager()? + // フラグメントトランザクションの開始 + FragmentTransaction transaction = manager.beginTransaction(); + // レイアウトをfragmentに置き換え(追加) + transaction.replace(R.id.fragmentContainerView, fragment); + // 置き換えのトランザクションをバックスタックに保存する + transaction.addToBackStack(null); + // フラグメントトランザクションをコミット + transaction.commit(); + } } \ No newline at end of file