0

So....i am trying to make this button change from main activity to Disciplinas_Activity. But whenever I try to run the app and click the button, the app crashes. Keep in mind i have other 3 button completly identical ,(other then the fact that they direct to different activities), in the same activity and they all work with the same base code.

Here is the .xml code for Main Activity

<TextView
    android:id="@+id/textView_emailnotverified"
    android:layout_width="172dp"
    android:layout_height="34dp"
    android:background="@color/white"
    android:text="Email não Verificado!"
    android:textColor="#E41F1F"
    android:textSize="18dp"
    android:visibility="gone"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintHorizontal_bias="0.066"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintVertical_bias="0.516" />

<TextView
    android:id="@+id/textView_studentEmail"
    android:layout_width="237dp"
    android:layout_height="40dp"
    android:text="Email do aluno"
    android:textColor="@color/white"
    android:textSize="18dp"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintHorizontal_bias="0.856"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintVertical_bias="0.395" />

<ImageView
    android:id="@+id/imageView4"
    android:layout_width="332dp"
    android:layout_height="168dp"
    android:scaleX="2"
    android:scaleY="1.3"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintHorizontal_bias="0.493"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintVertical_bias="0.028"
    app:srcCompat="@drawable/etpr" />

<TextView
    android:id="@+id/welcommingtextview5"
    android:layout_width="337dp"
    android:layout_height="39dp"
    android:text="ESCOLA TÉCNICA E PROFISSIONAL DO RIBATEJO"
    android:textAlignment="center"
    android:textColor="@color/white"
    android:textSize="8dp"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintHorizontal_bias="0.459"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintVertical_bias="0.15" />

<TextView
    android:id="@+id/ETPRTitle5"
    android:layout_width="258dp"
    android:layout_height="30dp"
    android:text="BEM-VINDO À ETPR"
    android:textAlignment="center"
    android:textColor="@color/white"
    android:textSize="24dp"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintHorizontal_bias="0.496"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintVertical_bias="0.105" />

<Button
    android:id="@+id/Button_LOGOUT"
    android:layout_width="114dp"
    android:layout_height="59dp"
    android:text="Logout"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintVertical_bias="0.934" />

<Button
    android:id="@+id/button_Testes"
    android:layout_width="108dp"
    android:layout_height="47dp"
    android:text="Testes"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintHorizontal_bias="0.867"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintVertical_bias="0.644" />

<Button
    android:id="@+id/button_pdf"
    android:layout_width="121dp"
    android:layout_height="41dp"
    android:text="PDF"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintHorizontal_bias="0.894"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintVertical_bias="0.753" />

<Button
    android:id="@+id/button_historia"
    android:layout_width="191dp"
    android:layout_height="47dp"
    android:text="Sobre o criador"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintHorizontal_bias="0.149"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintVertical_bias="0.76" />

<ImageView
    android:id="@+id/imageView_perfil"
    android:layout_width="122dp"
    android:layout_height="118dp"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintHorizontal_bias="0.055"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintVertical_bias="0.376"
    app:srcCompat="@mipmap/ic_launcher" />

<TextView
    android:id="@+id/textView_studentname"
    android:layout_width="236dp"
    android:layout_height="33dp"
    android:text="Nome do aluno"
    android:textColor="@color/white"
    android:textSize="18dp"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintHorizontal_bias="0.857"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintVertical_bias="0.329" />

<Button
    android:id="@+id/button_emailverification"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Verificar agora"
    android:visibility="gone"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintHorizontal_bias="0.88"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintVertical_bias="0.527" />

<Button
    android:id="@+id/changeprofileBTN"
    android:layout_width="245dp"
    android:layout_height="41dp"
    android:text="Mude a imagem de perfil"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintHorizontal_bias="0.897"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintVertical_bias="0.453" />

<Button
    android:id="@+id/button_disciplinas"
    android:layout_width="194dp"
    android:layout_height="55dp"
    android:text="Disciplinas"
    android:clickable="true"
    android:focusable="true"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintHorizontal_bias="0.106"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintVertical_bias="0.644" />

Here is my .java code for main activity

public class MainActivity extends AppCompatActivity {
TextView fullname, email, verifymessage;
FirebaseAuth fAuth;
FirebaseFirestore fstore;
String userID;
Button resendVerification, LogoutBTN, changeprofileBTN, tests, createrInfo, pdfdatabase, buttonDisciplinas;
ImageView profileImage;
StorageReference storageReference;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    fullname = findViewById(R.id.textView_studentname);
    email    = findViewById(R.id.textView_studentEmail);

    LogoutBTN      = (Button) findViewById(R.id.Button_LOGOUT);
    tests          =(Button) findViewById(R.id.button_Testes);
    createrInfo    =(Button) findViewById(R.id.button_historia);
    pdfdatabase    =(Button) findViewById(R.id.button_pdf);
    buttonDisciplinas = findViewById(R.id.button_disciplinas);

    buttonDisciplinas.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            startActivity(new Intent(MainActivity.this, Disciplinas_Activity.class));
        }
    });


    tests.setOnClickListener(new View.OnClickListener() {// menu dos testes
        @Override
        public void onClick(View v) {
            startActivity(new Intent(getApplicationContext(),Testes_Activity.class));
        }
    });

    createrInfo.setOnClickListener(new View.OnClickListener() {//página sobre a história da app
        @Override
        public void onClick(View v) {
            startActivity(new Intent(getApplicationContext(),AboutMe_Activity.class));
        }
    });

    pdfdatabase.setOnClickListener(new View.OnClickListener() {//pdf database
        @Override
        public void onClick(View v) {
            startActivity(new Intent(getApplicationContext(),PDF_Activity.class));
        }
    });

    LogoutBTN.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            FirebaseAuth.getInstance().signOut();
            startActivity(new Intent(getApplicationContext(),LoginScreen.class));
            finish();
        }
    });

    profileImage = findViewById(R.id.imageView_perfil);
    changeprofileBTN = findViewById(R.id.changeprofileBTN);

    fAuth    = FirebaseAuth.getInstance();
    fstore   = FirebaseFirestore.getInstance();
    storageReference = FirebaseStorage.getInstance().getReference();

    StorageReference profileRef = storageReference.child("utilizadores/"+fAuth.getCurrentUser().getUid()+"/perfil.jpg");
    profileRef.getDownloadUrl().addOnSuccessListener(new OnSuccessListener<Uri>() {
        @Override
        public void onSuccess(Uri uri) {
            Picasso.get().load(uri).into(profileImage);
        }
    });

    resendVerification = findViewById(R.id.button_emailverification);
    verifymessage      = findViewById(R.id.textView_emailnotverified);


    userID = fAuth.getCurrentUser().getUid();

    DocumentReference documentReference = fstore.collection("utilizadores").document(userID);
    documentReference.addSnapshotListener(this, new EventListener<DocumentSnapshot>() {
        @Override
        public void onEvent(@Nullable DocumentSnapshot documentSnapshot, @Nullable FirebaseFirestoreException error) {
            fullname.setText(documentSnapshot.getString("NomeCompleto"));
            email.setText(documentSnapshot.getString("Email"));
        }
    });


    FirebaseUser user = fAuth.getCurrentUser();

    if (!user.isEmailVerified()){
        verifymessage.setVisibility(View.VISIBLE);
        resendVerification.setVisibility(View.VISIBLE);

        resendVerification.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                user.sendEmailVerification().addOnSuccessListener(new OnSuccessListener<Void>() {
                    @Override
                    public void onSuccess(Void aVoid) {
                        Toast.makeText(v.getContext(),"Email de verificação enviado.", Toast.LENGTH_SHORT).show();
                    }
                }).addOnFailureListener(new OnFailureListener() {
                    @Override
                    public void onFailure(@NonNull Exception e) {
                        Log.d("tag","Erro: Email de verificação não enviado " + e.getMessage());

                    }
                });
            }
        });
    }

    changeprofileBTN.setOnClickListener(new View.OnClickListener() { //mudar imagem de perfil
        @Override
        public void onClick(View v) {
            Intent openGalleryIntent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
            startActivityForResult(openGalleryIntent,1000);
        }
    });
}

@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (requestCode == 1000 ){
        if (resultCode == Activity.RESULT_OK){//se o resultado for igual então abre  galeria
            Uri imageUri = data.getData();
            //profileImage.setImageURI(imageUri); //insere imagem escolhida na galeria

            uploadImageToFirebase(imageUri);
            
            
        }
    }
}

private void uploadImageToFirebase(Uri imageUri) { //upload da imagem para base de dados
    StorageReference fileReference = storageReference.child("utilizadores/"+fAuth.getCurrentUser().getUid()+"/perfil.jpg");
    fileReference.putFile(imageUri).addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
        @Override
        public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
            fileReference.getDownloadUrl().addOnSuccessListener(new OnSuccessListener<Uri>() {
                @Override
                public void onSuccess(Uri uri) {
                    Picasso.get().load(uri).into(profileImage);
                }
            });

        }
    }).addOnFailureListener(new OnFailureListener() {
        @Override
        public void onFailure(@NonNull Exception e) {
            Toast.makeText(MainActivity.this,"Erro", Toast.LENGTH_SHORT).show();
        }
    });
}

}

Here is .xml code for DisciplinasActivity

 <LinearLayout
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <RelativeLayout
        android:id="@+id/Relative_Layout_Title"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="20dp"
        android:layout_marginTop="32dp"
        android:layout_marginRight="20dp">

        <TextView
            android:id="@+id/Menu_Title"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Disciplinas"
            android:textColor="@color/white"
            android:textSize="22sp">
        </TextView>

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@id/Menu_Title"
            android:layout_marginTop="6dp"
            android:text="ETPR"
            android:textColor="@color/white"
            android:textSize="14sp">
        </TextView>

        <TextView
            android:id="@+id/Name_Data"
            android:textColor="@color/white"
            android:textSize="16sp"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_toStartOf="@id/user_icon"
            android:text="Nome">
        </TextView>

        <TextView
            android:id="@+id/Email_Data"
            android:textColor="@color/white"
            android:textSize="16dp"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@id/Name_Data"
            android:layout_toStartOf="@id/user_icon"
            android:text="Email">

        </TextView>

        <ImageView
            android:id="@+id/user_icon"
            android:layout_width="62dp"
            android:layout_height="62dp"
            android:layout_alignParentRight="true"
            app:srcCompat="@drawable/cara">
        </ImageView>

    </RelativeLayout>

    <GridLayout
        android:id="@+id/MainGrid"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="@+id/Relative_Layout_Title"
        android:alignmentMode="alignMargins"
        android:columnCount="2"
        android:columnOrderPreserved="false"
        android:rowCount="2">

        <androidx.cardview.widget.CardView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_rowWeight="1"
            android:layout_columnWeight="1"
            android:layout_margin="12dp"
            android:layout_marginTop="70dp"
            app:cardCornerRadius="12dp"
            app:cardElevation="6dp">

            <LinearLayout
                android:id="@+id/LinearLayoutSdac"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_gravity="center"
                android:orientation="vertical"
                android:padding="16dp">

                <ImageView
                    android:layout_width="80dp"
                    android:layout_height="80dp"
                    android:layout_gravity="center"
                    android:src="@drawable/sdac_icon"/>

                <TextView
                    android:layout_width="56dp"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center"
                    android:layout_marginTop="12dp"
                    android:text="SDAC"
                    android:textColor="@color/black"
                    android:textSize="18sp">
                </TextView>

            </LinearLayout>

        </androidx.cardview.widget.CardView>

        <androidx.cardview.widget.CardView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_rowWeight="1"
            android:layout_columnWeight="1"
            android:layout_margin="12dp"
            android:layout_marginTop="70dp"
            app:cardCornerRadius="12dp"
            app:cardElevation="6dp">

            <LinearLayout
                android:id="@+id/LinearLayoutEletronica"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_gravity="center"
                android:orientation="vertical"
                android:padding="16dp">

                <ImageView
                    android:layout_width="80dp"
                    android:layout_height="80dp"
                    android:layout_gravity="center"
                    android:src="@drawable/eletronica_icon"
                    app:srcCompat="@drawable/eletronica_icon" />

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center"
                    android:layout_marginTop="12dp"
                    android:text="Eletrónica"
                    android:textColor="@color/black"
                    android:textSize="18sp"/>

            </LinearLayout>

        </androidx.cardview.widget.CardView>

        <androidx.cardview.widget.CardView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_rowWeight="1"
            android:layout_columnWeight="1"
            android:layout_margin="12dp"
            android:layout_marginTop="70dp"
            app:cardCornerRadius="12dp"
            app:cardElevation="6dp">

            <LinearLayout
                android:id="@+id/LinearLayoutCD"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_gravity="center"
                android:orientation="vertical"
                android:padding="16dp">

                <ImageView
                    android:layout_width="80dp"
                    android:layout_height="80dp"
                    android:layout_gravity="center"
                    android:src="@drawable/cd_icon"
                    app:srcCompat="@drawable/cd_icon" />

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center"
                    android:layout_marginTop="12dp"
                    android:text="CD"
                    android:textColor="@color/black"
                    android:textSize="18sp" />

            </LinearLayout>

        </androidx.cardview.widget.CardView>

        <androidx.cardview.widget.CardView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_rowWeight="1"
            android:layout_columnWeight="1"
            android:layout_margin="12dp"
            android:layout_marginTop="70dp"
            app:cardCornerRadius="12dp"
            app:cardElevation="6dp">

            <LinearLayout
                android:id="@+id/LinearLayoutIMEI"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_gravity="center"
                android:orientation="vertical"
                android:padding="16dp">

                <ImageView
                    android:layout_width="80dp"
                    android:layout_height="80dp"
                    android:layout_gravity="center"
                    android:src="@drawable/imei_icon"
                    app:srcCompat="@drawable/imei_icon" />

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center"
                    android:layout_marginTop="12dp"
                    android:text="IMEI"
                    android:textColor="@color/black"
                    android:textSize="18sp" />

            </LinearLayout>

        </androidx.cardview.widget.CardView>

    </GridLayout>

    <Button
        android:id="@+id/ExitButton"
        android:layout_marginTop="20dp"
        android:layout_width="121dp"
        android:layout_height="69dp"
        android:layout_gravity="center"
        android:layout_marginBottom="@+id/RelativeLayout"
        android:text="Sair"
        android:textColor="@color/white"
        android:textSize="16dp" />

</LinearLayout>

Here is my .Java code for DisciplinasActivity

public class Disciplinas_Activity extends AppCompatActivity {

GridLayout gridPrincipal;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_disciplinas);

    gridPrincipal = (GridLayout)findViewById(R.id.MainGrid); //identifica qual a grelha


    //ação
    setSingleEvent(gridPrincipal);
}

private void setSingleEvent(GridLayout gridPrincipal) {
    for (int i =0;i<gridPrincipal.getChildCount();i++)
    {
        CardView cardView = (CardView)gridPrincipal.getChildAt(i);
        final int finalI = i;
        cardView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(new Intent(getApplicationContext(),TeacherLoginScreen.class));//muda para Disciplina de Sdac
            }
        });
    }
}

}

What am i missing...? if all the other 3 buttons work...why doesnt this one work? (I am a total newbie but i
I really need the help) 
  • 1
    Did you add the activity to the manifest file? – Hasbulla Mar 17 '21 at 22:03
  • you mean this? "" – Ivan Matias Mar 17 '21 at 22:04
  • Yes, make sure it's added in the AndroidManifest.xml file – Hasbulla Mar 17 '21 at 22:06
  • it is in there mate just like i wrote it previously – Ivan Matias Mar 17 '21 at 22:08
  • Have you tried using the debugger to get a look at the error message? – Hasbulla Mar 17 '21 at 22:09
  • Also, are you sure that `button1` is in `activity_main`? 2. Can you use `v.getContext();` instead of `getApplicationContext()` ? – javdromero Mar 17 '21 at 22:12
  • I did not remember that Here is the error: 03-17 22:12:59.140 19785-19785/studying.app.tkappv6 E/AndroidRuntime: FATAL EXCEPTION: main Process: studying.app.tkappv6, PID: 19785 java.lang.RuntimeException: Unable to start activity ComponentInfo{studying.app.tkappv6/studying.app.tkappv6.Disciplinas_Activity}: java.lang.UnsupportedOperationException: Can't convert to dimension: type=0x12 at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2325) And then just goes on like that – Ivan Matias Mar 17 '21 at 22:14
  • Try using "startActivity(new Intent(MainActivity.this, Disciplinas_Activity.class));" – Hasbulla Mar 17 '21 at 22:16
  • didnt work mate.... i replaced the old "startActivity(new Intent(getApplicationContext(),Disciplinas_Activity.class));" for the one you gave me but still nothing – Ivan Matias Mar 17 '21 at 22:19
  • Im out of ideas tho, what I would try now is to use the `onClickListener` for the button outside of `onCreate` instead of directly inside – Hasbulla Mar 17 '21 at 22:22
  • 2
    It's not how you are calling the activity, looking at your log it has something to be tih your Disciplinas_Activity layout, post the xml attached to that activity. – javdromero Mar 17 '21 at 22:33
  • @javdromero i have posted it now – Ivan Matias Mar 17 '21 at 22:56
  • @javdromero also, I have tried using v.getContext(); by replacing the one I used and still crashes – Ivan Matias Mar 17 '21 at 22:59
  • @GlennQuagmire I tried using onClickListener outside the onCreate but it doesnt allow me to use that onClickListener outside of the onCreate – Ivan Matias Mar 17 '21 at 23:00
  • You need to search for your error message: https://stackoverflow.com/q/18741485/208273 – Ryan M Mar 22 '21 at 00:27

3 Answers3

1

Consider your code

button = (Button)findViewById(R.id.button1);
  • You do not need to explicitly cast widgets anymore unless it's a special case like a RadioButton from a resource ID.
  • Please check that the button you're clicking is actually the button you set all this up for.
  • Add
android:clickable="true";
android:focusable="true";

to your buttons in the XML layout. I'm guessing ConstraintLayout is creating this problem, you shouldn't come across this issue if you use LinearLayout.

mindoverflow
  • 730
  • 4
  • 13
  • did not worked....i checked once again the Id of the button im trying to use and the id is correct. i deleted the "(button)" and i added the code "android:clickable="true" android:focusable="true"" you gave me but still not working.... – Ivan Matias Mar 17 '21 at 22:41
  • What happens if you replace ```getApplicationContext()``` with ```ActivityName.this```? – mindoverflow Mar 17 '21 at 22:43
  • like this? startActivity(new Intent(Disciplinas_Activity.this)); – Ivan Matias Mar 17 '21 at 23:03
  • No, ```startActivity(new Intent(CallingActivity.this, Disciplinas_Activity.class));``` like this. What is the Calling Activity Name? Replace it with CallingActivity. – mindoverflow Mar 17 '21 at 23:09
  • keeps crashing.... i see this error java.lang.UnsupportedOperationException: Can't convert to dimension: type=0x12 – Ivan Matias Mar 17 '21 at 23:17
  • Can you share your full code on the question? – mindoverflow Mar 17 '21 at 23:18
  • How did you type my code as? Paste the line here please. – mindoverflow Mar 17 '21 at 23:19
  • Code has been fully shared of both activities And this is how i wrote your code buttonDisciplinas.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { startActivity(new Intent(MainActivity.this, Disciplinas_Activity.class)); } }); – Ivan Matias Mar 17 '21 at 23:25
  • 1
    Im noticing your main activity xml has no layout. Is this your code or did you leave out something – mindoverflow Mar 17 '21 at 23:28
  • thanks a lot...if there is a way we could video chat and i could share the screen perhaps through discord or something. That is if you preffer that way. – Ivan Matias Mar 17 '21 at 23:28
1

In your .xml code for DisciplinasActivity you have some mistakes on the dimensions that you are using:

    <GridLayout
    ...
    android:id="@+id/MainGrid"
    ...
    android:layout_marginBottom="@+id/Relative_Layout_Title" <!-- E.G 20dp -->
    >
    
     <Button
    android:id="@+id/ExitButton"
    ...
    android:layout_marginBottom="@+id/RelativeLayout" <!-- E.G 20dp -->
    ... />

For margins, padding, etc you have to use a dimension, like dp,in,mm,etc not a reference to other view, or you could use dimmens.xml maybe you are confusing android:layout_marginBottom with android:layout_constraintBottom_toBottomOf or another property. Check for this in all the elements in your .xml

This answer is due to this log that you posted:

ComponentInfo{studying.app.tkappv6/studying.app.tkappv6.Disciplinas_Activity}: java.lang.UnsupportedOperationException: Can't convert to dimension: type=0x12

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
javdromero
  • 1,850
  • 2
  • 11
  • 19
0

In the MainActivity

Change the to "v.getContext()" istead of "MainActivity.this"

tests.setOnClickListener(new View.OnClickListener() {// menu dos testes
        @Override
        public void onClick(View v) {
            startActivity(new Intent(v.getContext(), Testes_Activity.class));
        }
    });

    createrInfo.setOnClickListener(new View.OnClickListener() {//página sobre a história da app
        @Override
        public void onClick(View v) {
            startActivity(new Intent(v.getContext(), AboutMe_Activity.class));
        }
    });

    pdfdatabase.setOnClickListener(new View.OnClickListener() {//pdf database
        @Override
        public void onClick(View v) {
            startActivity(new Intent(v.getContext(),PDF_Activity.class));
        }
    });

    LogoutBTN.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            FirebaseAuth.getInstance().signOut();
            startActivity(new Intent(v.getContext(),LoginScreen.class));
            finish();
        }
    });

I was Looking into the code and i've never used this method, but it's strange for me so it's good to pay attention, I think is wrong to set a "Void", if the method is not going to receive any value, but since is a @Override method if it was that way from the beginning you don't need to change;

@Override
public void onSuccess(Void aVoid) {
       Toast.makeText(v.getContext(),"Email de verificação enviado.", Toast.LENGTH_SHORT).show();
}

Give a try and let's see if works!

Dam
  • 320
  • 1
  • 5
  • 12