I do not end up with a problem because everyone is left unresolved, and now I find another, which I do not understand because it is happening, since I have seen other codes and it works correctly.
The problem is that I have put a button in a class that extends from AppCompatActivity , to call from that button a class that extends Fragment , by pressing the button the Fragment
is superimposed, seeing both.
This is one of the codes I've tried and I have put in Activity
to show the Fragment
Alarmas.java
public class Alarmas_Login extends AppCompatActivity
Code to show the Fragment
FragmentManager fragmentManager = getSupportFragmentManager();
FragmentTransaction transaction = fragmentManager.beginTransaction();
transaction.replace(R.id.container_login, new Alarmas());
transaction.addToBackStack(null);
transaction.commit();
alarms_login.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".Alarmas_Login">
<EditText
android:id="@+id/intro_login"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="56dp"
android:ems="10"
android:hint="Introducir Contraseña"
android:inputType="textPassword"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.502"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<Button
android:id="@+id/bt_aceptar"
style="@style/Widget.AppCompat.Button.Colored"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="Aceptar"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/intro_login" />
<FrameLayout
android:id="@+id/container_login"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
</FrameLayout>
</android.support.constraint.ConstraintLayout>
I would appreciate your help if someone can tell me how to show only one class.
Greetings.