I am new in android development. I'm trying to make a simple login and registration form. I have a TextView 'Sign up' which basically takes the user to the registerActivity when clicked on, but when everytime when i click on the sign up textView it crashes my app. I have searched for the solutions but i can't seem to figure out whats causing the crash.
XML:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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=".LoginActivity"
android:orientation="vertical"
android:gravity="center_horizontal"
android:background="@drawable/bg"
>
<ImageView
android:layout_width="wrap_content"
android:layout_height="200dp"
android:layout_marginTop="70dp"
app:srcCompat="@drawable/logo"
/>
<EditText
android:id="@+id/edittext_username"
android:layout_width="249dp"
android:layout_height="71dp"
android:layout_marginTop="20dp"
android:drawableLeft="@drawable/user"
android:drawablePadding="10dp"
android:textColorHint="#f8f8f8"
android:paddingLeft="15dp"
android:hint="@string/mobile"
android:textColor="#f8f8f8"
android:background="@drawable/rounded_edittext" />
<EditText
android:id="@+id/edittext_password"
android:layout_width="249dp"
android:layout_height="71dp"
android:layout_marginTop="20dp"
android:drawableLeft="@drawable/password"
android:drawablePadding="10dp"
android:textColorHint="#f8f8f8"
android:paddingLeft="15dp"
android:hint="@string/password"
android:textColor="#f8f8f8"
android:background="@drawable/rounded_edittext"/>
<Button
android:id="@+id/button_login"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:layout_marginTop="20dp"
android:background="@drawable/rounded_buttons"
android:text="@string/login"
/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="20dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="35dp"
android:text="Not Registered?"
android:textColor="#000000" />
<TextView
android:id="@+id/textview_register"
android:layout_width="wrap_content"
android:layout_height="35dp"
android:paddingLeft="5dp"
android:textStyle="bold"
android:textColor="#e8170c"
android:text="@string/register"/>
</LinearLayout>
JAVA:
package com.example.careerhunts.raw;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
public class LoginActivity extends AppCompatActivity {
EditText mTextUsername;
EditText mTextPassword;
Button mButtonLogin;
TextView mTextViewRegister;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE); //will hide the title
getSupportActionBar().hide(); // hide the title bar
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN); //enable full
screen
setContentView(R.layout.activity_login);
mTextUsername = findViewById(R.id.edittext_username);
mTextPassword = findViewById(R.id.edittext_password);
mButtonLogin = findViewById(R.id.button_login);
mTextViewRegister = findViewById(R.id.textview_register);
mTextViewRegister.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent registerIntent = new Intent(LoginActivity.this,
RegisterActivity.class);
startActivity(registerIntent);
}
});
}
}