So basically when I will click the register button it should direct me to the next page.I too wrote the code for this,But the button is getting clicked but it is not taking me next page.I mean next page is not getting opened.There is no error in the logcat section coming .It means my code is running ..But the page is not getting intended.
this is my new_user_login.xml file
<?xml version="1.0" encoding="UTF-8"?>
<RelativeLayout
tools:context=".NewUserActivity"
android:background="@drawable/ic_launcher_background"
android:layout_height="match_parent"
android:layout_width="match_parent"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android">
<TextView
android:id="@+id/textView4"
android:layout_width="276dp"
android:layout_height="38dp"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:layout_marginEnd="106dp"
android:layout_marginBottom="581dp"
android:text=" REGISTRATION "
android:textColor="@color/WhiteSmoke"
android:textSize="30dp" />
<EditText
android:id="@+id/name"
android:layout_width="298dp"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:layout_marginEnd="36dp"
android:layout_marginBottom="487dp" />
<TextView
android:id="@+id/textView5"
android:layout_width="218dp"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:layout_marginEnd="120dp"
android:layout_marginBottom="530dp"
android:drawableLeft="@drawable/ic_action_name"
android:text="NAME"
android:textColor="@color/WhiteSmoke"
android:textSize="20dp" />
<TextView
android:id="@+id/textView6"
android:layout_width="195dp"
android:layout_height="30dp"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:layout_marginEnd="138dp"
android:layout_marginBottom="440dp"
android:drawableLeft="@drawable/ic_action_mail"
android:text="EMAIL ID"
android:textColor="@color/WhiteSmoke"
android:textSize="20dp" />
<EditText
android:id="@+id/email"
android:layout_width="298dp"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:layout_marginEnd="36dp"
android:layout_marginBottom="388dp" />
<TextView
android:id="@+id/textView7"
android:layout_width="147dp"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:layout_marginEnd="186dp"
android:layout_marginBottom="351dp"
android:drawableLeft="@drawable/ic_action_phone"
android:text="PHONE NO."
android:textColor="@color/WhiteSmoke"
android:textSize="20dp" />
<EditText
android:id="@+id/phone"
android:layout_width="300dp"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:layout_marginEnd="36dp"
android:layout_marginBottom="306dp" />
<TextView
android:id="@+id/textView8"
android:layout_width="195dp"
android:layout_height="30dp"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:layout_marginEnd="135dp"
android:layout_marginBottom="254dp"
android:drawableLeft="@drawable/ic_action_username"
android:text="USERNAME"
android:textColor="@color/WhiteSmoke"
android:textSize="20dp" />
<EditText
android:id="@+id/usname"
android:layout_width="300dp"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:layout_marginEnd="36dp"
android:layout_marginBottom="205dp" />
<TextView
android:id="@+id/textView9"
android:layout_width="195dp"
android:layout_height="30dp"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:layout_marginEnd="131dp"
android:layout_marginBottom="165dp"
android:drawableLeft="@drawable/ic_action_password"
android:text="PASSWORD"
android:textColor="@color/WhiteSmoke"
android:textSize="20dp" />
<EditText
android:id="@+id/passsword"
android:layout_width="295dp"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:layout_marginEnd="36dp"
android:layout_marginBottom="113dp" />
<Button
android:id="@+id/register"
android:layout_width="324dp"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:layout_marginEnd="29dp"
android:layout_marginBottom="23dp"
android:background="@color/DeepPink"
android:fontFamily="sans-serif"
android:onClick="REGISTER"
android:text="REGISTER"
android:textColor="@color/Black"
android:textSize="24dp" />
</RelativeLayout>
this is my NewUserActivity.java class
public class NewUserActivity extends AppCompatActivity {
EditText name;
EditText email;
EditText phone;
EditText usname;
EditText passsword;
Button register;
ToastManager toastManager;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.new_user_login);
name = (EditText) findViewById(R.id.name);
email = (EditText) findViewById(R.id.email);
phone = (EditText) findViewById(R.id.phone);
usname = (EditText) findViewById(R.id.usname);
passsword = (EditText) findViewById(R.id.passsword);
register = (Button) findViewById(R.id.register);
register.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
String NAME = name.getText().toString().trim();
String EMAIL = email.getText().toString().trim();
String PHONENO = phone.getText().toString().trim();
String username = usname.getText().toString().trim();
String password = passsword.getText().toString().trim();
String emailPattern = "^[a-zA-Z0-9+_.-]{3,32}+@[a-zA-Z0-9.-]{2,32}+$";
String phonePattern = "(0/91)?[7-9][0-9]{9}";
boolean isAtLeastOneEditTextNotEmpty = !NAME.isEmpty()
|| !EMAIL.isEmpty()
|| !PHONENO.isEmpty()
|| !username.isEmpty()
|| !password.isEmpty();
// Create a new instance of ToastManager
ToastManager toastManager = new ToastManager(NewUserActivity.this);
// When one or all Edit Text are blank
if (isAtLeastOneEditTextNotEmpty) {
// NAME VALIDATION
if (NAME.isEmpty()) {
toastManager.addToast("ENTER NAME", ToastManager.Duration.LENGTH_SHORT);
} else if (!((NAME.length() > 3) && (NAME.length() < 15))) {
toastManager.addToast("NAME IS TOO SHORT.IT MUST BE BETWEEN 3-15 CHARACTERS.", ToastManager.Duration.LENGTH_SHORT);
} else if (!NAME.matches("[a-zA-Z ]+")) {
toastManager.addToast("ONLY ALPHABETS ALLOWED", ToastManager.Duration.LENGTH_SHORT);
}
//EMAIL VALIDATION
if (EMAIL.isEmpty()) {
toastManager.addToast("ENTER EMAIL-ID", ToastManager.Duration.LENGTH_SHORT);
} else if (!(EMAIL.matches(emailPattern))) {
toastManager.addToast("INVALID EMAIL", ToastManager.Duration.LENGTH_SHORT);
}
//PHONE NUMBER VALIDATION
if (PHONENO.isEmpty()) {
toastManager.addToast("ENTER PHONE NO.", ToastManager.Duration.LENGTH_SHORT);
} else if (!(PHONENO.length() == 10)) {
toastManager.addToast("INVALID PHONE NO.", ToastManager.Duration.LENGTH_SHORT);
} else if (!(PHONENO.matches(phonePattern))) {
toastManager.addToast("INVALID PHONE NO.", ToastManager.Duration.LENGTH_SHORT);
}
//USERNAME VALIDATION
if (username.isEmpty()) {
toastManager.addToast("ENTER USERNAME", ToastManager.Duration.LENGTH_SHORT);
} else if (!((username.length() > 6) && (username.length() < 15))) {
toastManager.addToast("USERNAME IS TOO SHORT.IT MUST BE BETWEEN 6-15 CHARACTERS.", ToastManager.Duration.LENGTH_SHORT);
}
//PASSWORD VALIDATION
if (password.isEmpty()) {
toastManager.addToast("ENTER PASSWORD", ToastManager.Duration.LENGTH_SHORT);
} else if (!((password.length() > 6) && (password.length() < 15))) {
toastManager.addToast("PASSWORD IS TOO SHORT.IT MUST BE BETWEEN 6-15 CHARACTERS.", ToastManager.Duration.LENGTH_SHORT);
}
} else {
toastManager.addToast("ALL FIELDS ARE COMPULSORY", ToastManager.Duration.LENGTH_SHORT);
}
// Finally show all toast all screen
toastManager.show();
}
});
}
@Override
protected void onStop() {
super.onStop();
}
public void REGISTER(View view) {
Button register =(Button)findViewById(R.id.register);
register.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent p = new Intent(getApplicationContext(),MainActivity2.class);
startActivity(p);
}
});
}
}
this is the code where i have intended next activity
public void REGISTER(View view) {
Button register =(Button)findViewById(R.id.register);
register.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent p = new Intent(getApplicationContext(),MainActivity2.class);
startActivity(p);
}
});
}
this is my manifest code
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.example.moviebookingapp2">
<application
android:allowBackup="true"
android:icon="@drawable/ticket"
android:label="Movie Booking App"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".SplashActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".MainActivity"></activity>
<activity android:name=".NewUserActivity"></activity>
<activity android:name=".MainActivity2"></activity>
<activity android:name=".IntroductionActivity"></activity>
<activity android:name=".MainActivity1"></activity>
<activity android:name=".PaymentActivity"></activity>
<activity android:name=".DebitActivity"></activity>
<activity android:name=".CreditActivity"></activity>
</application>
</manifest>