Quantcast
Channel: Active questions tagged crash - Stack Overflow
Viewing all articles
Browse latest Browse all 7190

How to solve the Navigation from one activity to Other Activity without any compile error? [closed]

$
0
0

I am working on a Login App. In 1st Activity the user has the option called "create account" [button]. And 2nd Activity is about the filling the user details.When I click the "create account" button the apps gets closed.There is no compilation error.Could someone help me out the error..?Second Activity XML:

<?xml version="1.0" encoding="utf-8"?><androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"    xmlns:tools="http://schemas.android.com/tools"    android:layout_width="match_parent"    android:layout_height="match_parent"    xmlns:app="http://schemas.android.com/apk/res-auto"><androidx.cardview.widget.CardView        android:id="@+id/cardview_userdetails"        android:layout_width="350dp"        android:layout_height="50dp"        android:layout_marginTop="16dp"        app:cardBackgroundColor="#25232B"        app:cardCornerRadius="25dp"        app:layout_constraintEnd_toEndOf="parent"        app:layout_constraintStart_toStartOf="parent"        app:layout_constraintTop_toTopOf="parent"><RelativeLayout            android:layout_width="match_parent"            android:layout_height="match_parent"><TextView                android:id="@+id/textview_welcome"                android:layout_width="wrap_content"                android:layout_height="wrap_content"                android:layout_centerInParent="true"                android:text="@string/user_details"                android:textColor="#ffffff"                android:textSize="20sp"                android:textStyle="bold|italic" /></RelativeLayout></androidx.cardview.widget.CardView><EditText        android:id="@+id/edittext_username"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:layout_marginTop="16dp"        android:drawableStart="@drawable/username"        android:drawableLeft="@drawable/username"        android:ems="10"        android:hint="@string/username_email"        android:inputType="textPersonName"        app:layout_constraintEnd_toEndOf="parent"        app:layout_constraintStart_toStartOf="parent"        app:layout_constraintTop_toBottomOf="@+id/cardview_userdetails"        tools:ignore="MissingConstraints" /><EditText        android:id="@+id/edittext_password"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:layout_marginTop="16dp"        android:drawableLeft="@drawable/password"        android:ems="10"        android:hint="@string/password"        android:inputType="textPassword"        app:layout_constraintEnd_toEndOf="parent"        app:layout_constraintStart_toStartOf="parent"        app:layout_constraintTop_toBottomOf="@+id/edittext_username"        android:drawableStart="@drawable/password" /><EditText        android:id="@+id/edittext_confirmPassword"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:layout_marginTop="16dp"        android:drawableLeft="@drawable/password"        android:ems="10"        android:hint="@string/confirm_password"        android:inputType="textPassword"        app:layout_constraintEnd_toEndOf="parent"        app:layout_constraintStart_toStartOf="parent"        app:layout_constraintTop_toBottomOf="@+id/edittext_password"        android:drawableStart="@drawable/password" /><EditText        android:id="@+id/edittext_phoneNumber"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:layout_marginTop="16dp"        android:ems="10"        android:hint="@string/phone_number"        android:inputType="textPhonetic"        app:layout_constraintEnd_toEndOf="parent"        app:layout_constraintStart_toStartOf="parent"        app:layout_constraintTop_toBottomOf="@+id/edittext_confirmPassword"        tools:ignore="TextFields" /><EditText        android:id="@+id/edittext_emailAddress"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:layout_marginTop="16dp"        android:ems="10"        android:hint="@string/email_id"        android:inputType="textEmailAddress"        app:layout_constraintEnd_toEndOf="parent"        app:layout_constraintStart_toStartOf="parent"        app:layout_constraintTop_toBottomOf="@+id/edittext_phoneNumber" /><Button        android:id="@+id/button_registerUser"        android:layout_width="116dp"        android:layout_height="48dp"        android:layout_marginStart="16dp"        android:layout_marginLeft="16dp"        android:layout_marginTop="16dp"        android:layout_marginEnd="16dp"        android:layout_marginRight="16dp"        android:layout_marginBottom="16dp"        android:background="#6BAF1B"        android:gravity="center"        android:textColor="#0E0E0E"        android:text="@string/register_user"        app:layout_constraintBottom_toBottomOf="parent"        app:layout_constraintEnd_toEndOf="parent"        app:layout_constraintStart_toStartOf="parent"        app:layout_constraintTop_toBottomOf="@+id/edittext_emailAddress" /></androidx.constraintlayout.widget.ConstraintLayout>

Second Activity Java Class file:

package com.android.loginapp;import android.os.Bundle;import androidx.annotation.Nullable;import androidx.appcompat.app.AppCompatActivity;public class RegistrationActivity extends AppCompatActivity {    @Override    protected void onCreate(@Nullable Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        setContentView(R.layout.registration_activity);    }}

The first Activity file java code:

public class MainActivity extends AppCompatActivity {    private EditText EditTextUserName;    private EditText EditTextUserPassword;    private Button buttonLogin;    private Button buttonReset;    private Button buttonCreateUser;    @Override    protected void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        setContentView(R.layout.login_activity);        EditTextUserName = (EditText) findViewById(R.id.edittext_username);        EditTextUserPassword = (EditText) findViewById(R.id.edittext_password);        buttonLogin = (Button) findViewById(R.id.button_login);        buttonReset = (Button) findViewById(R.id.button_reset);        buttonCreateUser = (Button) findViewById(R.id.button_createaccount);        //Reset function        buttonReset.setOnClickListener(new View.OnClickListener() {            @Override            public void onClick(View v) {                EditTextUserName.setText("");                EditTextUserPassword.setText("");            }        });        //Create a new user function        buttonCreateUser.setOnClickListener(new View.OnClickListener() {            @Override            public void onClick(View v) {                Intent registerIntent = new Intent(MainActivity.this,RegistrationActivity.class);                startActivity(registerIntent);            }        });    }}

Viewing all articles
Browse latest Browse all 7190

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>