Question: public class SignUpActivity extends AppCompatActivity { private EditText userName, userPassword, userEmail; private Button signUpButton; private TextView userLogin; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_sign_up);
public class SignUpActivity extends AppCompatActivity { private EditText userName, userPassword, userEmail; private Button signUpButton; private TextView userLogin; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_sign_up); setupUIView(); signUpButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (validate()){ // Upload data to the database } } }); userLogin.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { startActivity(new Intent(SignUpActivity.this, MainActivity.class)); } }); } private void setupUIView(){ userName = (EditText) findViewById(R.id.etUserName); userPassword = (EditText) findViewById(R.id.etUserPassword); userEmail = (EditText) findViewById(R.id.etUserEmail); signUpButton = (Button) findViewById(R.id.btnSignUp); } private Boolean validate(){ Boolean result = false; String name = userName.getText().toString(); String password = userPassword.getText().toString(); String email = userEmail.getText().toString(); if(name.isEmpty() || password.isEmpty() || email.isEmpty()){ Toast.makeText(this, "Please enter all the details!", Toast.LENGTH_SHORT).show(); }else{ result = true; } return result; } }
Here is a code for an activity, when I try to run it using Android Studio, I get the message:
app/src/main/res/values/strings.xml: Error: Found item String/etUserName more than one time
Can someone tell me how I can fix this problem?
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
