Tesis 1.0.0
Loading...
Searching...
No Matches
SuccessRegistryFragment.java
Go to the documentation of this file.
1package com.example.food_front;
2
3import android.os.Bundle;
4
5import androidx.fragment.app.Fragment;
6import androidx.fragment.app.FragmentManager;
7import androidx.fragment.app.FragmentTransaction;
8
9import android.view.LayoutInflater;
10import android.view.View;
11import android.view.ViewGroup;
12import android.widget.Button;
13
14
15public class SuccessRegistryFragment extends Fragment {
16
17
19 // Required empty public constructor
20 }
21
22 @Override
23 public View onCreateView(LayoutInflater inflater, ViewGroup container,
24 Bundle savedInstanceState) {
25 // Inflate the layout for this fragment
26 View view = inflater.inflate(R.layout.fragment_success_registry, container, false);
27 Button button = view.findViewById(R.id.button);
28 button.setOnClickListener(new View.OnClickListener() {
29 @Override
30 public void onClick(View v) {
31 replaceFragment(new HomeFragment()); // Replace with another fragment
32 }
33 });
34
35 return view;
36 }
37
38 private void replaceFragment(Fragment newFragment) {
39 // Get the FragmentManager and start a transaction
40
41 FragmentManager fragmentManager = requireActivity().getSupportFragmentManager();
42 FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
43 fragmentTransaction.replace(R.id.fragment_container_view, newFragment);
44 fragmentTransaction.addToBackStack(null);
45 fragmentTransaction.commit();
46 }
47}
View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)