package com.example.fragmentorientation;

import android.os.Bundle;

import androidx.fragment.app.Fragment;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;


public class fragmentTwo extends Fragment {

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        return inflater.inflate(R.layout.fragment_two, container, false);
    }

    @Override
    public void onStart(){
        super.onStart();
        Button btnGetText = getActivity().findViewById(R.id.btnFragmentTwo);
        btnGetText.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                TextView txtView = getActivity().findViewById(R.id.tvFragmentOne);
                Toast.makeText(getActivity(), txtView.getText(), Toast.LENGTH_LONG).show();
            }
        });
    }
}