The error is:

Unable to start activity ComponentInfo{com.example.basicapp/com.example.basicapp.SignupActivity}: java.lang.ClassCastException: androidx.appcompat.widget.AppCompatEditText cannot be cast to com.google.android.material.textfield.TextInputEditText

This error is displayed in LogCat; however, in reality the app crashes when I click the intended button who's onClick is set to launch_signup.

This happened when I was perhaps playing with the Android manifest file which does not directly mean that the issue be derived from there. though it perhaps may.

This is the section of the code in Login.java where I have tried starting a new activity:

public void launch_signup(View v) {
        //launch a new activity
        Intent i = new Intent(this, SignupActivity.class); //instantiation of a new object of type Intent; acts as a constructor, "this" refers to the current activity in the class
        startActivity(i);

}

This is the top of the file for any reference:

package com.example.basicapp;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

public class Login extends AppCompatActivity {

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


This is the manifest file:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools">

    <application
        android:allowBackup="true"
        android:dataExtractionRules="@xml/data_extraction_rules"
        android:fullBackupContent="@xml/backup_rules"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/Theme.BasicApp"
        tools:targetApi="31">
        <activity
            android:name=".Login"
            android:exported="true"> 
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <activity
            android:name=".SignupActivity"
            android:exported="false" />
        <activity
            android:name=".MainActivity"
            android:exported="true"
            android:label="MediCare">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

My purpose is to simply click on the sign up button and be directed to a new activity which I already have a truck load of code written for which is SignupActivity.java. I have also tried explicitly using the onClickListener method instead by creating objects but that did not work. Instead of just having the, "this" in the intent code, I tried, "getApplicationContext", "Login.this". I do not know what happened, before everything was fine.

0

There are 0 best solutions below