1 answer

This java code allows to proceed to next activity even if no data is enetered. add...

Question:

this java code allows to proceed to next activity even if no data is enetered. add a constraint which displays a message to fill all fields.   import androidx.appcompat.app.AppCompatActivity;  import android.content.Intent; import android.os.Bundle; import android.util.Log; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.Toast;  public class SignupActivity extends AppCompatActivity {      EditText editTextName,editTextEmail,editTextPhone,editTextPswd,editTextCPswd,editTextAge,editTextFatherName;     Button btnMoveToLogin;     @Override     protected void onCreate(Bundle savedInstanceState) {         super.onCreate(savedInstanceState);         setContentView(R.layout.activity_signup);         editTextName=findViewById(R.id.editTextName);         editTextFatherName=findViewById(R.id.editTextFatherName);         editTextAge=findViewById(R.id.editTextAge);         editTextPhone=findViewById(R.id.editTextPhoneNumber);         editTextPswd=findViewById(R.id.editTextPswd);         editTextCPswd=findViewById(R.id.editTextCPswd);         editTextEmail=findViewById(R.id.editTextEmail);         btnMoveToLogin=findViewById(R.id.buttonMoveToLogIn);         btnMoveToLogin.setOnClickListener(new View.OnClickListener() {             @Override             public void onClick(View v) {                 Log.i("Name",editTextEmail.getText().toString());                 if(editTextEmail.getText().toString()=="" && editTextFatherName.getText().toString()=="" && editTextPhone.getText().toString()=="" && editTextPswd.getText().toString()=="" && editTextCPswd.getText().toString()=="" && editTextName.getText().toString()=="" && editTextAge.getText().toString()==""){                     Toast.makeText(SignupActivity.this, "Please enter all the fields", Toast.LENGTH_SHORT).show();                     return;                 }                 if(editTextCPswd.getText().toString()==editTextPswd.getText().toString()){                     Toast.makeText(SignupActivity.this, "Passwords do not match!!", Toast.LENGTH_SHORT).show();                 }else{                     Intent intent=new Intent(SignupActivity.this, LoginActivity.class);                     startActivity(intent);                 }             }         });     } } 

Answers

import androidx.appcompat.app.AppCompatActivity;

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

public class SignupActivity extends AppCompatActivity {

EditText editTextName,editTextEmail,editTextPhone,editTextPswd,editTextCPswd,editTextAge,editTextFatherName;
Button btnMoveToLogin;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_signup);
editTextName=findViewById(R.id.editTextName);
editTextFatherName=findViewById(R.id.editTextFatherName);
editTextAge=findViewById(R.id.editTextAge);
editTextPhone=findViewById(R.id.editTextPhoneNumber);
editTextPswd=findViewById(R.id.editTextPswd);
editTextCPswd=findViewById(R.id.editTextCPswd);
editTextEmail=findViewById(R.id.editTextEmail);
      
btnMoveToLogin=findViewById(R.id.buttonMoveToLogIn);
  
       btnMoveToLogin.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Log.i("Name",editTextEmail.getText().toString());
              
               // if any of the text field is not populated , show toast message
               // trim is used to remove trailing and leading spaces
               // length is used to return the number of characters in the string
if(editTextEmail.getText().toString().trim().length() == 0 || editTextFatherName.getText().toString().trim().length() == 0 || editTextPhone.getText().toString().trim().length() == 0 || editTextPswd.getText().toString().trim().length() == 0 || editTextCPswd.getText().toString().trim().length() == 0 || editTextName.getText().toString().trim().length() == 0 ||
               editTextAge.getText().toString().trim().length() == 0){
Toast.makeText(SignupActivity.this, "Please enter all the fields", Toast.LENGTH_SHORT).show();
  
}else{
                   // if passwords do not match, show toast message
                   if(!editTextCPswd.getText().toString().equals(editTextPswd.getText().toString()))
                   {
                       Toast.makeText(SignupActivity.this, "Passwords do not match!!", Toast.LENGTH_SHORT).show();
                   }else{
                       // All fields are populated and passwords match, hence proceed to the next activity
                       Intent intent=new Intent(SignupActivity.this, LoginActivity.class);
                       startActivity(intent);
                   }
}
}
});
}
}

.

Similar Solved Questions

1 answer
9. A 45 kVA, 120 V: 280 V, single-phase transformer is to be connected as an...
9. A 45 kVA, 120 V: 280 V, single-phase transformer is to be connected as an autotransformer. Determine the voltage ratings of the of the high and low voltage windings for this connection and the kVA rating for the autotransformer connection. Ans: 280V:400V, 150 kVA...
1 answer
D Troy Engines, Ltd., manufactures a variety of engines for use in heavy equipment. The company...
d Troy Engines, Ltd., manufactures a variety of engines for use in heavy equipment. The company has always produced all of the necessary parts for its engines, including all of the carburetors. An outside supplier has offered to sell one type of carburetor to Troy Engines, Ltd., for a cost of $36 pe...
1 answer
(10 Points) 5- Operation Managers play a very key role in the success of any organizations....
(10 Points) 5- Operation Managers play a very key role in the success of any organizations. Identifty a) The key functional areas of a typical organization Enumerate as many decision areas w management responsibilities. b) ithin an organization that falls within the o...
1 answer
If exactly three darts hit this target, how many different scores are possible
If exactly three darts hit this target, how many different scores are possible?darts circle135...
1 answer
Let R be the region bounded by the following curves. Use the shell method to find...
Let R be the region bounded by the following curves. Use the shell method to find the volume of the solid generated when R is revolved about the x-axis. y=2 - xy-x, and y=0 Set up the integral that gives the volume of the sold. Use increasing limits of integration. Select the correct choice below an...
1 answer
K. FINI TRANSFER FUNCTIONS Hyls) H2(S) BETWEEN AT Put valt de undues vsalt) & Vsąlt), RESPERTIvey....
K. FINI TRANSFER FUNCTIONS Hyls) H2(S) BETWEEN AT Put valt de undues vsalt) & Vsąlt), RESPERTIvey. Use MESE TRANSFER Funer TONS TO HELP FIND. THE ZERO-STATE RESPONSE Vect) when Uselt)= 1001t)V, 23464)=etelu 22 HINT: SUPERPOSITION! 4 234 t) + this + usele ) Ult) Osalt) 21...
1 answer
In a test of weight loss programs, 120 subjects were divided such that 40 subjects followed...
In a test of weight loss programs, 120 subjects were divided such that 40 subjects followed each of 3 diets. Each was weighed a year after starting the diet and the results are in the ANOVA table below. Use a 0.05 significance level to test the claim that the mean weight loss is the same for the dif...
1 answer
1 / 4 x ² 1x2 and y A large tank is designed with ends in...
1 / 4 x ² 1x2 and y A large tank is designed with ends in the shape of the region between the curves y = 20, measured in feet. Find the hydrostatic force on one end of the tank if it is filled to a depth of 12 ft with gasoline. (Assume the gasoline's density is 42.0 lb/ft3. Round your answe...
1 answer
Two identical probes are sent along the same path toward a neutron star. A neutron star...
Two identical probes are sent along the same path toward a neutron star. A neutron star is very dense, packing as much as 2 solar masses into a sphere with a radius on the order of 10 km. At the moment shown, the two probes are 57.5 km and 118 km away from the center of the neutron star, respectivel...
1 answer
Question completion Status: QUESTION 37 Disturbance is any discrete event in time that disrupts community structure...
Question completion Status: QUESTION 37 Disturbance is any discrete event in time that disrupts community structure and changes the abiotic environment True False QUESTION 38 community When there are high levels of disturbance in a community, the number of K-selected species should increase along wi...
1 answer
Selected operating data for two divisions of Outback Brewing, Ltd., of Australia are given below Division...
Selected operating data for two divisions of Outback Brewing, Ltd., of Australia are given below Division New South Queensland s 1,891,000 Wales 2,700,000 540,000 135,000 211,000 Sales Average operating assets Net operating income Property, plant, and equipment (net) S 610,000 151,280 261,000 S Requ...
3 answers
Short mood pieces of no set form are called _____
Short mood pieces of no set form are called _____.a. tone poemsb. preludesc. overturesd. mazurkas B?...
1 answer
The practice of Conuco, involves growing a variety of compatible plants in a relatively small area....
The practice of Conuco, involves growing a variety of compatible plants in a relatively small area. This is also called 1) Monoculture. O2) Polyculture 3) Paraculture 4) Fair trade...
1 answer
I only need part C solved as that is where I am stuck. if it could...
I only need part C solved as that is where I am stuck. if it could be done in steps showing how to get to the final answer that would be very helpful. I am posting for a second time because the first time it was answered here the anon put just the final answers. OL: (17 points) Magnum Inc. is con...
1 answer
Create a free body diagram then find the action reaction of the load COSC 321 Structural...
create a free body diagram then find the action reaction of the load COSC 321 Structural Systems / Assignment #1 Force's Actions and Reactions AM TEXAS A&M UNIVERSITY 2020 Spring Q1 10K W=2k/ft OB А....
1 answer
NEED EXCEL SOLUTION: EXCEL FORMULA ONLY PLEASE Calculate WACC: Debt Weight: 60.00% Equity Weight: 40.00% Tax...
NEED EXCEL SOLUTION: EXCEL FORMULA ONLY PLEASE Calculate WACC: Debt Weight: 60.00% Equity Weight: 40.00% Tax rate: 35.00% WACC: Use CAPM Cost of Equity The below information is given. I need to solve for WACC. Cost of Equity: Stock quote link S...
1 answer
A collector is using a magnifying lens with a radius of curvature of 21.0 cm to...
A collector is using a magnifying lens with a radius of curvature of 21.0 cm to examine the finer details of a butterfly with a magnification of 5.10. At what distance between the butterfly and the lens does she achieve the desired magnification?...