Hope the weekend is going well. I am working on login and registration pages and having a hard time finding a solution to an unchecked cast error and after checking, it seemed everything is fine on the xml code. the challenge is really frustrating, Here is the code please
java code
public class RegistrationPage < Button > extends AppCompatActivity {
EditText emailId, password;
Button btnSignin;
TextView tvSign_Up;
FirebaseAuth mFirebaseAuth;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_registration_page);
mFirebaseAuth = FirebaseAuth.getInstance();
emailId = findViewById(R.id.editTextTextEmailAddress);
password = findViewById(R.id.editTextTextPassword);
btnSignin = (Button) findViewById(R.id.Sign_In);
tvSign_Up = (findViewById(R.id.textView2));
btnSignin.(new RegistrationPage < > () View.OnClickListener(("v"))) - > {
@Override
public void onClick(View "V") {
string email = emailId.getText().toString();
string pwd = password.getText().toString();
if (((String) email).isEmpty()) {
emailId.setError("Please Enter Correct Email Address");
emailId.requestFocus();
}
The xml code
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.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=".RegistrationPage">
<EditText
android:id="@+id/editTextTextEmailAddress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="84dp"
android:layout_marginLeft="84dp"
android:layout_marginTop="152dp"
android:layout_marginEnd="85dp"
android:layout_marginRight="85dp"
android:layout_marginBottom="313dp"
android:autofillHints=""
android:ems="10"
android:hint="@string/email"
android:inputType="textEmailAddress"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<EditText
android:id="@+id/editTextTextPassword"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="85dp"
android:layout_marginLeft="85dp"
android:layout_marginEnd="85dp"
android:layout_marginRight="85dp"
android:autofillHints=""
android:ems="10"
android:hint="@string/password"
android:inputType="textPassword"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/editTextTextEmailAddress"
app:layout_constraintVertical_bias="0.092" />
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="29dp"
android:layout_marginBottom="200dp"
android:text="@string/already_have_an_account_sign_in_here"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.498"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/editTextTextPassword"
app:layout_constraintVertical_bias="0.677" />
<Button
android:id="@+id/Sign_In"
android:layout_width="wrap_content"
android:layout_height="48dp"
android:layout_marginStart="50dp"
android:layout_marginLeft="50dp"
android:layout_marginTop="24dp"
android:layout_marginEnd="50dp"
android:layout_marginRight="50dp"
android:text="@string/sign_up"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/editTextTextPassword"
app:layout_constraintVertical_bias="0.054" />
</androidx.constraintlayout.widget.ConstraintLayout>
Any help will be appreciated greatly
Seems like there is some coding format errors. Replace your above java code with this and try it out: