TestHomeFragment.java
1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package com.polysoft.nafmii.fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import com.whaty.nafmii.R;
public class TestHomeFragment extends Fragment {
public static Fragment newInstance(String value) {
TestHomeFragment fragment = new TestHomeFragment();
Bundle bundle = new Bundle();
bundle.putString("text", value);
fragment.setArguments(bundle);
return fragment;
}
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater,
@Nullable ViewGroup container,
@Nullable Bundle savedInstanceState) {
super.setHasOptionsMenu(true);
return inflater.inflate(R.layout.test_fragment, null, false);
}
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
String text = getArguments().getString("text");
TextView tv = view.findViewById(R.id.test_fragment_text);
tv.setText(text);
}
}