I have a class of type Fragment
and I would like that when the user clicks on the button it would go to another screen that is fragment .. how can I do this?
public class AlertaFragment extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_alerta, container, false);
FloatingActionButton fab = (FloatingActionButton) view.findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
.setAction("Action", null).show();
}
});
return view;
}
}
@EDIT
I put it like this: He makes the argument red ...
final FragmentTransaction ft = getFragmentManager().beginTransaction();
CadastroAlertaFragment cadastro = new CadastroAlertaFragment();
ft.replace(R.id.cadastro_frag, cadastro, cadastro.getTag());
ft.commit();
Error:
Error:(167, 48) error: incompatible types: CadastroAlertaFragment cannot be converted to Fragment