mirror of
https://github.com/lacerta-doc/Lacerta.git
synced 2024-11-23 00:13:16 +00:00
データを取得するための機能実装
This commit is contained in:
parent
e34dd65dda
commit
9d108212dd
|
@ -1,11 +1,26 @@
|
|||
package one.nem.lacerta.feature.library;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
public class LibraryXFragment extends Fragment {
|
||||
|
||||
// フラグメントが作成された際に呼ばれるメソッド
|
||||
private TextView textView; // フィールドとして TextView を定義
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
View view = inflater.inflate(R.layout.fragment_library_file, container, false);
|
||||
|
||||
textView = view.findViewById(R.id.textView);
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
@ -14,7 +29,10 @@ public class LibraryXFragment extends Fragment {
|
|||
if (getArguments() != null) {
|
||||
String receivedData = getArguments().getString("key_name");
|
||||
|
||||
// ここで receivedData を使って何か処理を行う
|
||||
// onCreateView メソッドで取得した TextView にデータをセットする
|
||||
if (textView != null) {
|
||||
textView.setText(receivedData);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:padding="16dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="16sp"
|
||||
android:layout_marginEnd="8dp"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
Loading…
Reference in New Issue
Block a user