Java 无法将android.widget.ProgressBar强制转换为android.widget.RelativeLayout

Java 无法将android.widget.ProgressBar强制转换为android.widget.RelativeLayout,java,android-studio,Java,Android Studio,我是安卓工作室的新手。目前,我在android上开发medlabtut应用程序已经3个多月了。MedLabStartUpScreen上的登录按钮出现问题,当单击该按钮时,实际上应该启动登录屏幕。相反,它会使应用程序完全崩溃,并在我的login.java类文件的//连接钩子“progressbar=findViewById(R.id.login\u progress\u bar);”处显示运行时异常,该android.widget.progressbar不能强制转换为android.widget.

我是安卓工作室的新手。目前,我在android上开发medlabtut应用程序已经3个多月了。MedLabStartUpScreen上的登录按钮出现问题,当单击该按钮时,实际上应该启动登录屏幕。相反,它会使应用程序完全崩溃,并在我的login.java类文件的//连接钩子“progressbar=findViewById(R.id.login\u progress\u bar);”处显示运行时异常,该android.widget.progressbar不能强制转换为android.widget.RelativeLayout。我需要你的帮助

我的登录布局活动

<?xml version="1.0" encoding="utf-8"?>
<ScrollView 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=".Common.LoginSignup.Login"
    android:orientation="vertical"
    android:background="#fff"
    android:padding="25dp"
    android:transitionName="transition_login">

<LinearLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:orientation="vertical">
    
         

<TextView
            android:id="@+id/logo_name"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:text="Welcome Back! Login Here"
            android:textSize="40sp"
            android:transitionName="logo_text"
            android:fontFamily="@font/bungee"
            android:textColor="#000"
            android:layout_marginTop="20dp"/>

   



<TextView
            android:id="@+id/slogan_name"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Sign In to continue"
            android:textSize="18sp"
            android:layout_marginTop="10dp"
            android:fontFamily="@font/muli_black"
            android:transitionName="logo_desc"/>

        

<RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="30dp"
                android:layout_marginBottom="20dp">

            

<com.hbb20.CountryCodePicker
                    android:id="@+id/login_country_code_picker"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    app:ccp_autoDetectCountry="true"
                    app:ccp_showFlag="true"
                    app:ccp_showNameCode="true"
                    app:ccp_showFullName="true"
                    android:padding="5dp"
                    android:background="@drawable/black_border"/>

           



<com.google.android.material.textfield.TextInputLayout
                    android:layout_width="match_parent"
                    android:layout_below="@+id/login_country_code_picker"
                    android:id="@+id/login_phone_number"
                    android:layout_height="wrap_content"
                    style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
                    android:hint="@string/phone_number"
                    android:textColorHint="@color/Black"
                    app:boxStrokeColor="@color/Black"
                    app:boxStrokeWidthFocused="2dp"
                    app:endIconMode="clear_text"
                    app:endIconTint="@color/Black"
                    app:hintTextColor="@color/Black"
                    app:startIconDrawable="@drawable/field_phone_number_icon"
                    app:startIconTint="@color/Black">

                

<com.google.android.material.textfield.TextInputEditText
                        android:id="@+id/login_phone_number_editText"
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:inputType="phone" />
  
</com.google.android.material.textfield.TextInputLayout>



<com.google.android.material.textfield.TextInputLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/login_password"
        android:layout_below="@+id/login_phone_number"
        android:hint="@string/password"
        app:startIconDrawable="@drawable/field_password_icon"
        app:startIconTint="@color/Black"
        android:transitionName="password_tran"
        app:passwordToggleEnabled="true"
        app:passwordToggleTint="@color/Black"
        style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox">

        <com.google.android.material.textfield.TextInputEditText
            android:id="@+id/login_password_editText"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:fontFamily="@font/muli_bold"
            android:inputType="textPassword" />

    </com.google.android.material.textfield.TextInputLayout>


<RelativeLayout
        android:id="@+id/forget_password_block"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/login_password"
        android:layout_marginTop="10dp">

        <CheckBox
            android:id="@+id/remember_me"
            style="@style/Widget.AppCompat.CompoundButton.CheckBox"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerVertical="true"
            android:text="@string/remember_me" />
        
        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/forget_password"
            android:background="#00000000"
            android:layout_alignParentEnd="true"
            android:onClick="callForgetPassword"
            android:layout_alignParentRight="true"/>

    </RelativeLayout>



 <Button
        android:id="@+id/letTheUserLogin"
        android:layout_below="@+id/forget_password_block"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="10dp"
        android:layout_marginTop="5dp"
        android:background="#000"
        android:text="@string/login"
        android:onClick="letTheUserLoggedIn"
        android:textColor="#fff"
        android:transitionName="button_tran" />

<RelativeLayout
    android:id="@+id/login_sign_google_box"
    android:layout_width="match_parent"
    android:layout_height="50dp"
    android:padding="10dp"
    android:layout_margin="5dp"
    android:background="@drawable/rounded_rectangle"
    android:layout_below="@+id/letTheUserLogin">

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/signin_with_google_icon"
        android:layout_centerVertical="true"/>

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="SIGN IN WITH GOOGLE"
        android:layout_centerHorizontal="true"
        android:layout_centerInParent="true"
        android:fontFamily="@font/muli_bold"
        android:layout_margin="5dp"
        android:textColor="#000"/>

    <Button
        android:id="@+id/google_signIn"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@color/transparent" />

</RelativeLayout>

            

<Button
                android:id="@+id/signup_screen"
                android:layout_below="@+id/login_sign_google_box"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="#00000000"
                android:text="Create Account"
                android:layout_centerHorizontal="true"
                android:elevation="0dp"
                android:layout_margin="5dp"
                android:textColor="#000"
                android:transitionName="login_signup_tran"/>

            

<RelativeLayout
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:padding="20dp"
                    android:layout_centerInParent="true"
                    android:background="@drawable/white_circle"
                    android:elevation="10dp">

                    <ProgressBar
                        android:id="@+id/login_progress_bar"
                        android:layout_width="30dp"
                        android:layout_height="30dp"
                        android:layout_centerInParent="true"/>

                </RelativeLayout>

                

<ImageView
                        android:id="@+id/social_fb"
                        android:layout_below="@+id/signup_screen"
                        android:layout_width="50dp"
                        android:layout_height="45dp"
                        android:src="@drawable/social_facebook_icon"
                        android:layout_marginLeft="130dp" />

                

<ImageView
                        android:id="@+id/social_tw"
                        android:layout_below="@id/signup_screen"
                        android:layout_width="45dp"
                        android:layout_height="45dp"
                        android:layout_centerHorizontal="true"
                        android:layout_marginLeft="150dp"
                        android:src="@drawable/social_twitter_icon" />
                

<ImageView
                        android:id="@+id/social_wh"
                        android:layout_width="45dp"
                        android:layout_height="45dp"
                        android:layout_below="@id/signup_screen"
                        android:layout_marginLeft="250dp"
                        android:src="@drawable/social_whatsapp_icon" />

        

</RelativeLayout>

 </LinearLayout>

和login.java类文件的代码

public class Login extends AppCompatActivity {

    CountryCodePicker countryCodePicker;
    Button callSignUp, login_btn;
    TextView logoText, sloganText;
    TextInputLayout username, phoneNumber, password;
    RelativeLayout progressbar;
    CheckBox rememberMe;
    EditText phoneNumberEditText, passwordEditText;
    private GoogleSignInClient mGoogleSignInClient;
    private  final  static int RC_SIGN_IN = 123; // request code

    Button verify;
    private FirebaseAuth mAuth;
@Override
protected void onStart() {
    super.onStart();

    FirebaseUser user = mAuth.getCurrentUser();
    if (user!=null){
        Intent intent = new Intent(getApplicationContext(), MedLabDashboard.class);
        startActivity(intent);
    }
}




 @SuppressLint("WrongViewCast")
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,    WindowManager.LayoutParams.FLAG_FULLSCREEN);
        setContentView(R.layout.activity_login);

        mAuth = FirebaseAuth.getInstance();

        createRequest();

        //when the user clicks the google button,call the signIn method
        findViewById(R.id.google_signIn).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                signIn();
            }
        });



//Connection Hooks
    countryCodePicker = findViewById(R.id.country_code_picker);
    phoneNumber = findViewById(R.id.login_phone_number);
    progressbar = findViewById(R.id.login_progress_bar);
    callSignUp = findViewById(R.id.signup_screen);
    image = findViewById(R.id.logo_image);
    logoText = findViewById(R.id.logo_name);
    sloganText = findViewById(R.id.slogan_name);
    password = findViewById(R.id.login_password);
    login_btn = findViewById(R.id.Login_btn);
    rememberMe =  findViewById(R.id.remember_me);
    phoneNumberEditText = findViewById(R.id.login_phone_number_editText);
    passwordEditText = findViewById(R.id.login_password_editText);




//Check whether phone number and password is already saved in Shared Preference or not
    SessionManager sessionManager = new SessionManager(Login.this, SessionManager.SESSION_REMEMBERME);
    if (sessionManager.checkRemeberMe()){
        HashMap<String,String> rememberMeDetails = sessionManager.getRememberMeDetailFromSession();
        phoneNumberEditText.setText(rememberMeDetails.get(SessionManager.KEY_SESSIONPHONENUMBER));
        passwordEditText.setText(rememberMeDetails.get(SessionManager.KEY_SESSIONPASSWORD));
    }



 callSignUp.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Intent intent = new Intent(Login.this, SignUp.class);

            Pair[] pairs = new Pair[7];
            pairs[0] = new Pair<View, String>(image, "logo_image");
            pairs[1] = new Pair<View, String>(logoText, "logo_name");
            pairs[2] = new Pair<View, String>(sloganText, "logo_desc");
            pairs[3] = new Pair<View, String>(username, "username_tran");
            pairs[4] = new Pair<View, String>(password, "password_tran");
            pairs[5] = new Pair<View, String>(login_btn, "button_tran");
            pairs[6] = new Pair<View, String>(callSignUp, "login_signup_tran");

            if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
                try {

                    startActivity(intent);

                } catch (Exception e) {

                    e.printStackTrace();
                }
            }
        }
    });
}




//Setting Auto Google Sign In request
private void createRequest() {
    // Configure Google Sign In
    GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
            .requestIdToken(getString(R.string.default_web_client_id))
            .requestEmail()
            .build();

    // Build a GoogleSignInClient with the options specified by gso.
    mGoogleSignInClient = GoogleSignIn.getClient(this, gso);
}

//SignIn with google method that'll pop-up user google accounts (Intent)
private void signIn() {
    Intent signInIntent = mGoogleSignInClient.getSignInIntent();
    startActivityForResult(signInIntent, RC_SIGN_IN);
}




@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    // Result returned from launching the Intent from GoogleSignInClient.getSignInIntent(...);
    if (requestCode == RC_SIGN_IN) {
        Task<GoogleSignInAccount> task = GoogleSignIn.getSignedInAccountFromIntent(data);
        try {
            //Google Sign in was successful, authenticate with firebase
            GoogleSignInAccount account = task.getResult(ApiException.class);
            firebaseAuthWithGoogle(account);
        } catch (ApiException e){
            //Sign in failed, update UI appropriately
            Toast.makeText(this, e.getMessage(), Toast.LENGTH_SHORT).show();
        }
    }
}



 private void firebaseAuthWithGoogle(GoogleSignInAccount acct) {
        AuthCredential credential = GoogleAuthProvider.getCredential(acct.getIdToken(), null);
        mAuth.signInWithCredential(credential)
                .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
                    @Override
                    public void onComplete(@NonNull Task<AuthResult> task) {
                        if (task.isSuccessful()) {
                            // Sign in success, update UI with the signed-in user's information
                            FirebaseUser user = mAuth.getCurrentUser();
                            Intent intent = new Intent(getApplicationContext(), MedLabDashboard.class);
                            startActivity(intent);
                        } else {
                            Toast.makeText(Login.this, "Sorry authentication failed", Toast.LENGTH_SHORT).show();
                        }
                    }
                });
             }

//login the user in app
public void letTheUserLoggedIn(View view) {

    //Check the internet connection
    CheckInternet checkInternet = new CheckInternet();
    if (!isConnected(Login.this)) {
        showCustomDialog();
    }

    //validate user and password
    if (!validateFields()) {
        return;
    }
    progressbar.setVisibility(View.VISIBLE);

    //get value from fields
    String _phoneNumber = phoneNumber.getEditText().getText().toString().trim();
    final String _password = password.getEditText().getText().toString().trim();
    if (_phoneNumber.charAt(0) == '0') { //if the user uses proceeding zero (0)
        _phoneNumber = _phoneNumber.substring(1);
    }


    final String _completePhoneNumber = "+" + countryCodePicker.getFullNumber() + _phoneNumber;




//Remember me checkbox
    if (rememberMe.isChecked()){
        SessionManager sessionManager = new SessionManager(Login.this,SessionManager.SESSION_REMEMBERME);
        sessionManager.createRememberMeSession(_phoneNumber, _password);
    }

    //database query if user exist or not
    Query checkUser = FirebaseDatabase.getInstance().getReference("Users").orderByChild("phoneNo").equalTo(_completePhoneNumber);
    checkUser.addListenerForSingleValueEvent(new ValueEventListener() {
        @Override
        public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
            if (dataSnapshot.exists()) { //if the data has arrived or exists
                phoneNumber.setError(null); //if there's any error on the phoneNumber, remove
                phoneNumber.setErrorEnabled(false); //if there is error space, set to false

                String systemPassword = dataSnapshot.child(_completePhoneNumber).child("password").getValue(String.class);

                //if password exist and matches with users password, then get other fields from firebase database
                if (systemPassword.equals(_password)) {
                    password.setError(null); //if there's any error on the password, remove
                    password.setErrorEnabled(false); //if there is error space, set to false

                    String _fullname = dataSnapshot.child(_completePhoneNumber).child("fullName").getValue(String.class);
                    String _username = dataSnapshot.child(_completePhoneNumber).child("username").getValue(String.class);
                    String _email = dataSnapshot.child(_completePhoneNumber).child("email").getValue(String.class);
                    String _phoneNo = dataSnapshot.child(_completePhoneNumber).child("phoneNo").getValue(String.class);
                    String _password = dataSnapshot.child(_completePhoneNumber).child("password").getValue(String.class);
                    String _dateOfBirth = dataSnapshot.child(_completePhoneNumber).child("date").getValue(String.class);
                    String _gender = dataSnapshot.child(_completePhoneNumber).child("gender").getValue(String.class);

                    //Create a session
                    SessionManager sessionManager = new SessionManager(Login.this, SessionManager.SESSION_USERSESSION);
                    sessionManager.createLoginSession(_fullname, _username, _email, _phoneNo, _password, _dateOfBirth, _gender);

                    startActivity(new Intent(getApplicationContext(), MedLabDashboard.class));

                    Toast.makeText(Login.this, _fullname + "\n" + _email + "\n" + _phoneNo + "\n" + _dateOfBirth, Toast.LENGTH_SHORT).show();
                    progressbar.setVisibility(View.GONE);

                } else {
                    progressbar.setVisibility(View.GONE);
                    Toast.makeText(Login.this, "Password does not match!",  Toast.LENGTH_SHORT).show();
                }
            } else {
                progressbar.setVisibility(View.GONE);
                Toast.makeText(Login.this, "No such user exist", Toast.LENGTH_SHORT).show();
            }
        }

        @Override
        public void onCancelled(@NonNull DatabaseError databaseError) {
            progressbar.setVisibility(View.GONE);
            Toast.makeText(Login.this, databaseError.getMessage(), Toast.LENGTH_SHORT).show();
        }
    });
}


//check internet connection
private boolean isConnected(Login login) {
    ConnectivityManager connectivityManager = (ConnectivityManager)   login.getSystemService(Context.CONNECTIVITY_SERVICE);

    NetworkInfo wifiConn = connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
    NetworkInfo mobileConn = connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE);

    if ((wifiConn != null && wifiConn.isConnected()) || (mobileConn != null && mobileConn.isConnected())) {
        return true;
    } else {
        return false;
    }
}

private void showCustomDialog() {

    AlertDialog.Builder builder = new AlertDialog.Builder(Login.this);
    builder.setMessage("Please connect to the internet to continue");
    builder.setCancelable(false)
            .setPositiveButton("Connect", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialogInterface, int i) {
                    startActivity(new Intent(Settings.ACTION_WIFI_SETTINGS));
                }
            })
            .setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialogInterface, int i) {
                    startActivity(new Intent(getApplicationContext(), MedLabStartUpScreen.class));
                    finish();
                }
            });
         }



private boolean validateFields() {

    String _phoneNumber = phoneNumber.getEditText().getText().toString().trim();
    String _password = password.getEditText().getText().toString().trim();

    if (_phoneNumber.isEmpty()) {
        phoneNumber.setError("Phone number cannot be empty");
        phoneNumber.requestFocus();
        return false;
    } else if (_password.isEmpty()) {
        password.setError("Password cannot be empty");
        password.requestFocus();
        return false;
    } else {
        password.setError(null);
        password.setErrorEnabled(false);
        return true;
    }
}



public void callForgetPassword(View view){
    startActivity(new Intent(getApplicationContext(), ForgetPassword.class));
}

@Override
public void onBackPressed() {
    Intent a = new Intent(Intent.ACTION_MAIN);
    a.addCategory(Intent.CATEGORY_HOME);
    a.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    startActivity(a);
    finish();
}}
公共类登录扩展了AppCompatActivity{
CountryCodePicker CountryCodePicker;
按钮调用注册、登录\u btn;
text查看logoText,sloganText;
TextInputLayout用户名、电话号码、密码;
相对进度条;
复选框记忆;
EditText电话号码EditText,密码EditText;
私人谷歌签名客户端mGoogleSignInClient;
私有最终静态int RC\u SIGN\u IN=123;//请求代码
按钮验证;
私人消防队;
@凌驾
受保护的void onStart(){
super.onStart();
FirebaseUser=mAuth.getCurrentUser();
如果(用户!=null){
Intent Intent=newintent(getApplicationContext(),MedLabDashboard.class);
星触觉(意向);
}
}
@SuppressLint(“错误视图投射”)
@凌驾
创建时受保护的void(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_全屏,WindowManager.LayoutParams.FLAG_全屏);
setContentView(R.layout.activity\u登录);
mAuth=FirebaseAuth.getInstance();
createRequest();
//当用户单击google按钮时,调用signIn方法
findViewById(R.id.google_sign).setOnClickListener(新视图.OnClickListener(){
@凌驾
公共void onClick(视图){
签名();
}
});
//连接钩
countryCodePicker=findViewById(R.id.country\u code\u picker);
phoneNumber=findViewById(R.id.login\u phone\u number);
progressbar=findviewbyd(R.id.login\u progress\u bar);
callSignUp=findviewbyd(R.id.signup\u屏幕);
image=findviewbyd(R.id.logo\u图像);
logoText=findviewbyd(R.id.logo\u名称);
sloganText=findviewbyd(R.id.sloganText\u name);
password=findviewbyd(R.id.login\u密码);
login\u btn=findviewbyd(R.id.login\u btn);
rememberMe=findViewById(R.id.remember\u me);
phoneNumberEditText=findViewById(R.id.login\u phone\u number\u editText);
passwordEditText=findViewById(R.id.login\u password\u editText);
//检查电话号码和密码是否已保存在共享首选项中
SessionManager SessionManager=新的SessionManager(Login.this,SessionManager.SESSION\u REMEMBERME);
if(sessionManager.checkRemeberMe()){
HashMap-RememberDetails=sessionManager.GetRememberDetailFromSession();
setText(rememberMeDetails.get(SessionManager.KEY_SESSIONPHONENUMBER));
passwordEditText.setText(rememberMeDetails.get(SessionManager.KEY_SESSIONPASSWORD));
}
callSignUp.setOnClickListener(新视图.OnClickListener(){
@凌驾
公共void onClick(视图){
意图=新意图(Login.this、SignUp.class);
Pair[]pairs=新的Pair[7];
配对[0]=新配对(图像,“徽标_图像”);
配对[1]=新配对(logoText,“logo_name”);
配对[2]=新配对(sloganText,“logo_desc”);
配对[3]=新配对(用户名,“username_tran”);
pairs[4]=新对(密码,“password_tran”);
配对[5]=新配对(登录“按钮传送”);
pairs[6]=新对(callSignUp,“login\u signup\u tran”);
if(android.os.Build.VERSION.SDK\u INT>=android.os.Build.VERSION\u code.LOLLIPOP){
试一试{
星触觉(意向);
}捕获(例外e){
e、 printStackTrace();
}
}
}
});
}
//设置自动Google登录请求
私有void createRequest(){
//配置谷歌登录
GoogleSignenOptions gso=新建GoogleSignenOptions.Builder(GoogleSignenOptions.DEFAULT\u登录)
.requestIdToken(getString(R.string.default\u web\u client\u id))
.requestEmail()
.build();
//使用gso指定的选项构建GoogleSignInClient。
mGoogleSignInClient=GoogleSignIn.getClient(this,gso);
}
//使用google方法登录,该方法将弹出用户google帐户(意图)
私人无效签名(){
Intent-signinint=mGoogleSignInClient.getsigninint();
startActivityForResult(签名、注册);
}
@凌驾
ActivityResult上的公共void(int请求代码、int结果代码、意图数据){
super.onActivityResult(请求代码、结果代码、数据);
//从GoogleSignInClient.GetSignInent(…)启动Intent返回的结果;
if(requestCode==RC\u登录){
Task Task=GoogleSignIn.GetSignedAccountFromIntent(数据);
试一试{
//Google登录成功,通过firebase验证
GoogleSignInAccount account=task.getResult(ApiException.class);
firebaseAuthWithGoogle(账户);
}捕获(APIE){
//登录失败,请适当更新UI
Toast.makeText(this,e.getMessage(),Toast.LENGTH_SHORT.show();
}
}
}
私有void firebaseAuthWithGoogle(谷歌签名帐户){
Aut
<?xml version="1.0" encoding="utf-8"?>
<ScrollView 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"
    android:background="@color/White"
    android:padding="30dp"
    tools:context=".Common.LoginSignup.MedLabStartUpScreen">

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical">

    <ImageView
        android:layout_width="match_parent"
        android:layout_height="300dp"
        android:src="@drawable/splash_screen" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_marginTop="120dp"
        android:fontFamily="@font/muli_black"
        android:text="@string/medlab_heading"
        android:textAlignment="center"
        android:textAllCaps="true"
        android:textColor="@color/Black"
        android:textSize="36sp" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:fontFamily="@font/muli_light"
        android:text="@string/medlab_tab_line"
        android:textAlignment="center"
        android:textColor="@color/Black" />




<LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="40dp">

        <Button
            android:id="@+id/login_btn"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_marginRight="10dp"
            android:layout_marginEnd="10dp"
            android:onClick="callLoginScreen"
            android:layout_weight="1"
            android:background="@color/colorPrimaryDark"
            android:text="@string/login"
            android:textColor="@color/Black"
            tools:ignore="ButtonStyle"
            android:transitionName="transition_login"/>

        <Button
            android:id="@+id/signup_btn"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_marginLeft="10dp"
            android:layout_weight="1"
            android:background="@color/colorPrimaryDark"
            android:text="@string/sign_up"
            android:textColor="@color/Black" />

    </LinearLayout>

<Button
        android:layout_width="match_parent"
        android:layout_weight="1"
        android:layout_height="wrap_content"
        android:text="@string/how_we_work"
        android:textColor="@color/Black"
        android:layout_marginTop="20dp"
        android:background="#00000000"/>

</LinearLayout>

</ScrollView>
public class MedLabStartUpScreen extends AppCompatActivity {

        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
            setContentView(R.layout.activity_med_lab_start_up_screen);
        }



public void callLoginScreen(View view){
        Intent intent = new Intent(getApplicationContext(), Login.class);

        Pair[] pairs = new Pair[1];
        pairs[0] = new Pair<View,String>(findViewById(R.id.login_btn), "transition_login");

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            ActivityOptions options = ActivityOptions.makeSceneTransitionAnimation(MedLabStartUpScreen.this, pairs);
            startActivity(intent, options.toBundle());
        }
        else {
            startActivity(intent);
        }
    }
 }