import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.Toast;
public class MainActivity extends AppCompatActivity {
EditText txtUser;
EditText txtPass;
Spinner spnTUser;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
spnTUser = findViewById(R.id.spnTUser);
txtUser = findViewById(R.id.txtUser);
txtPass = findViewById(R.id.txtPass);
}
public void iniciar(View v) {
String type = spnTUser.getSelectedItem().toString();
String pass = txtPass.getText().toString();
switch (type){
case "Administrator":
if(pass.equals("a")){
Intent trypass = new Intent(MainActivity.this, Adminitration.class);
trypass.putExtra("user", txtUser.getText().toString());
startActivity(trypass);
} else {
Toast err = Toast.makeText(getApplicationContext(), "Usuario Incorrecto", Toast.LENGTH_SHORT);
err.show();
}
break;
case "Customer":
if(pass.equals("c")){
Intent trypasscus = new Intent(this, customer.class);
trypasscus.putExtra("user", txtUser.getText().toString());
startActivity(trypasscus);
} else {
Toast err = Toast.makeText(getApplicationContext(), "Usuario Incorrecto", Toast.LENGTH_SHORT);
err.show();
}
break;
case "Support":
if(pass.equals("s")){
Intent trypasssu = new Intent(this, support.class);
trypasssu.putExtra("user", txtUser.getText().toString());
startActivity(trypasssu);
} else {
Toast err = Toast.makeText(getApplicationContext(), "Usuario Incorrecto", Toast.LENGTH_SHORT);
err.show();
}
break;
}
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout 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=".MainActivity">
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout 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=".MainActivity">
<EditText
android:id="@+id/txtUser"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="48dp"
android:layout_marginTop="100dp"
android:ems="10"
android:hint="@string/user"
android:inputType="textPersonName"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="100dp"
android:text="@string/user"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="204dp"
android:text="@string/contrase_a"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<EditText
android:id="@+id/txtPass"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="48dp"
android:layout_marginTop="188dp"
android:ems="10"
android:hint="@string/contrase_a"
android:inputType="textPassword"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<Spinner
android:id="@+id/spnTUser"
android:layout_width="236dp"
android:layout_height="61dp"
android:layout_marginBottom="220dp"
android:layout_marginEnd="4dp"
android:layout_marginStart="8dp"
android:entries="@array/val_spin"
android:prompt="@string/tipo_de_usuario"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.428"
app:layout_constraintStart_toEndOf="@+id/textView5" />
<TextView
android:id="@+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="248dp"
android:layout_marginStart="16dp"
android:text="@string/tipo_de_usuario"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent" />
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:onClick="iniciar"
android:text="@string/iniciar_sesi_n"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.465"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.741" />
</android.support.constraint.ConstraintLayout>
</android.support.constraint.ConstraintLayout>
import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.widget.TextView;
public class Adminitration extends AppCompatActivity {
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.TextView;
public class Adminitration extends AppCompatActivity {
TextView tvWel;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_adminitration);
Bundle extras = getIntent().getExtras();
String user = extras.getString("user");
tvWel = findViewById(R.id.tvWelsu);
tvWel.setText(user);
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout 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=".Adminitration">
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout 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=".Adminitration">
<TextView
android:id="@+id/tvWelad"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="56dp"
android:textSize="40sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</android.support.constraint.ConstraintLayout>
</android.support.constraint.ConstraintLayout>