TestHomeFragment.java 1.27 KB
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);
    }
}