From 3386418abd49fb2e98dec204542df7431b204bb4 Mon Sep 17 00:00:00 2001 From: nero Date: Wed, 20 Dec 2023 12:21:37 +0900 Subject: [PATCH] =?UTF-8?q?=E7=94=BB=E9=9D=A2=E5=A4=89=E7=A7=BB=E3=81=AE?= =?UTF-8?q?=E3=82=B3=E3=83=BC=E3=83=89=E4=BD=9C=E6=88=90=E3=80=82=20?= =?UTF-8?q?=E3=83=87=E3=83=BC=E3=82=BF=E3=82=92=E5=8F=97=E3=81=91=E5=8F=96?= =?UTF-8?q?=E3=82=8B=E5=81=B4=E3=81=A8=E6=B8=A1=E3=81=99=E5=81=B4=E3=82=92?= =?UTF-8?q?=E4=BD=9C=E3=81=A3=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../library/LibraryArchiveFragment.java | 24 ++++++++++++-- .../feature/library/LibraryXFragment.java | 32 +++++++++++++++++++ 2 files changed, 54 insertions(+), 2 deletions(-) create mode 100644 feature/library/src/main/java/one/nem/lacerta/feature/library/LibraryXFragment.java diff --git a/feature/library/src/main/java/one/nem/lacerta/feature/library/LibraryArchiveFragment.java b/feature/library/src/main/java/one/nem/lacerta/feature/library/LibraryArchiveFragment.java index eabd2038..732033a4 100644 --- a/feature/library/src/main/java/one/nem/lacerta/feature/library/LibraryArchiveFragment.java +++ b/feature/library/src/main/java/one/nem/lacerta/feature/library/LibraryArchiveFragment.java @@ -20,8 +20,28 @@ public class LibraryArchiveFragment extends AppCompatActivity { @Override public void onClick(View v) { // 文字をタップしたときの処理 - Intent intent = new Intent(LibraryArchiveFragment.this, LibraryArchiveFragment.class); - startActivity(intent); + + // 移動先のアクティビティを指定 + Intent intent = new Intent(LibraryArchiveFragment.this, LibraryXFragment.class); + + // または、移動先のフラグメントを指定 + // Intent intent = new Intent(LibraryArchiveFragment.this, TargetFragment.class); + + startActivity(intent);textView.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + // 文字をタップしたときの処理 + + // 移動先のアクティビティを指定 + Intent intent = new Intent(LibraryArchiveFragment.this, TargetActivity.class); + + // データを付加する + intent.putExtra("key_name", "value_data"); + + startActivity(intent); + } + }); + } }); } diff --git a/feature/library/src/main/java/one/nem/lacerta/feature/library/LibraryXFragment.java b/feature/library/src/main/java/one/nem/lacerta/feature/library/LibraryXFragment.java new file mode 100644 index 00000000..2205efa9 --- /dev/null +++ b/feature/library/src/main/java/one/nem/lacerta/feature/library/LibraryXFragment.java @@ -0,0 +1,32 @@ +package one.nem.lacerta.feature.library; + +import android.os.Bundle; +import androidx.fragment.app.Fragment; + +public class LibraryXFragment extends Fragment { + + // フラグメントが作成された際に呼ばれるメソッド + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + // フラグメントに渡されたデータを取得 + if (getArguments() != null) { + String receivedData = getArguments().getString("key_name"); + + // ここで receivedData を使って何か処理を行う + } + } + + // Factory method for creating a new instance of the fragment + public static LibraryXFragment newInstance(String data) { + LibraryXFragment fragment = new LibraryXFragment(); + + // フラグメントにデータを渡す + Bundle args = new Bundle(); + args.putString("key_name", data); + fragment.setArguments(args); + + return fragment; + } +}