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; + } +}