仿拉手团购App5--登录界面_移动开发_编程开发_程序员俱乐部

中国优秀的程序员网站程序员频道CXYCLUB技术地图
热搜:
更多>>
 
您所在的位置: 程序员俱乐部 > 编程开发 > 移动开发 > 仿拉手团购App5--登录界面

仿拉手团购App5--登录界面

 2017/5/17 5:32:14  ganchuanpu  程序员俱乐部  我要评论(0)
  • 摘要:activity_login.xml<?xmlversion="1.0"encoding="utf-8"?><LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"xmlns:tools="http://schemas.android.com/tools"android:layout_width="match_parent"android
  • 标签:团购 APP

    

 

 

 

 

 

activity_login.xml

class="brush:java;gutter:true;"><?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context="com.myxh.coolshopping.ui.activity.LoginActivity">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="@dimen/common_titleBar_height"
        android:background="@color/title_bar_color">
        <ImageView
            android:id="@+id/login_titleBar_iv_back"
            style="@style/common_left_back_imageView_style"/>
        <TextView
            style="@style/base_textView_style"
            android:layout_centerInParent="true"
            android:gravity="center_vertical"
            android:text="@string/login_titleBar_login"
            android:textSize="@dimen/login_titleBar_login_size"
            android:textColor="@color/textColor_32"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"/>
        <TextView
            android:id="@+id/login_titleBar_tv_register"
            style="@style/common_right_title_textView_style"
            android:gravity="center"
            android:text="@string/login_titleBar_register"
            android:textColor="@color/orange"
            android:textSize="@dimen/login_titleBar_register_size"/>
    </RelativeLayout>

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:background="@color/bg_common_gray"
        android:scrollbars="none">

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

            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="@drawable/white_border_area">
                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="horizontal">
                    <TextView
                        android:id="@+id/login_select_tv_quickLogin"
                        style="@style/login_select_textView_style"
                        android:text="@string/login_select_quick_login"
                        android:textColor="@color/app_yellow"/>
                    <View
                        style="@style/me_vertical_view_style"/>
                    <TextView
                        android:id="@+id/login_select_tv_accountLogin"
                        style="@style/login_select_textView_style"
                        android:text="@string/login_select_account_login"/>
                </LinearLayout>
                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_alignParentBottom="true"
                    android:orientation="horizontal">
                    <View
                        android:id="@+id/login_select_left_line"
                        android:layout_width="0dp"
                        android:layout_height="@dimen/login_select_line_height"
                        android:layout_weight="1"
                        android:background="@color/orange"/>
                    <View
                        android:id="@+id/login_select_right_line"
                        android:layout_width="0dp"
                        android:layout_height="@dimen/login_select_line_height"
                        android:layout_weight="1"
                        android:background="@color/orange"
                        android:visibility="invisible"/>
                </LinearLayout>
            </RelativeLayout>

            <LinearLayout
                android:id="@+id/login_quick_login_layout"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="@dimen/login_layout_marginTop"
                android:orientation="vertical">
                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="vertical"
                    android:background="@color/app_white">
                    <RelativeLayout
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content">
                        <EditText
                            android:id="@+id/login_quick_login_et_phoneNumber"
                            style="@style/login_editText_style"
                            android:inputType="number"
                            android:maxLength="11"
                            android:hint="@string/login_input_phoneNumber_hint"/>
                        <ImageView
                            android:id="@+id/login_quick_login_iv_clear_phoneNumber"
                            android:visibility="gone"
                            style="@style/common_clear_input_imageView_style"/>
                    </RelativeLayout>
                    <View
                        style="@style/me_horizontal_view_style"/>
                    <RelativeLayout
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content">
                        <EditText
                            android:id="@+id/login_quick_login_et_code"
                            style="@style/login_editText_style"
                            android:inputType="number"
                            android:maxLength="6"
                            android:hint="@string/login_input_check_code_hint"/>
                        <Button
                            android:id="@+id/login_quick_login_btn_getCode"
                            style="@style/login_btn_getCode_style"/>
                        <ImageView
                            android:id="@+id/login_quick_login_iv_clear_code"
                            android:layout_toLeftOf="@+id/login_quick_login_btn_getCode"
                            android:layout_alignParentRight="false"
                            android:visibility="gone"
                            style="@style/common_clear_input_imageView_style"/>
                    </RelativeLayout>
                    <RelativeLayout
                        android:id="@+id/ll_check_picture"
                        android:layout_width="fill_parent"
                        android:layout_height="wrap_content"
                        android:orientation="horizontal"
                        android:visibility="gone" >

                        <View
                            android:layout_width="fill_parent"
                            android:layout_height="1.0dip"
                            android:layout_marginLeft="14.0dip"
                            android:background="#ffdadada" />

                        <EditText
                            android:id="@+id/et_check_picture"
                            android:layout_width="120.0dip"
                            android:layout_height="wrap_content"
                            android:layout_centerVertical="true"
                            android:background="@null"
                            android:hint="验证图片"
                            android:padding="16.0dip"
                            android:scrollHorizontally="true"
                            android:singleLine="true"
                            android:textColorHint="@color/gray01"
                            android:textSize="@dimen/size_24" />

                        <ImageView
                            android:id="@+id/iv_check_picture"
                            android:layout_width="50.0dip"
                            android:layout_height="30.0dip"
                            android:layout_centerVertical="true"
                            android:layout_toRightOf="@id/et_check_picture"
                            android:scaleType="fitXY" />
                    </RelativeLayout>
                </LinearLayout>
                <Button
                    android:id="@+id/login_quick_login_btn"
                    style="@style/login_btn_style"/>
            </LinearLayout>

            <LinearLayout
                android:id="@+id/login_account_login_layout"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="@dimen/login_layout_marginTop"
                android:orientation="vertical"
                android:visibility="gone">
                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="vertical"
                    android:background="@color/app_white">
                    <RelativeLayout
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content">
                        <EditText
                            android:id="@+id/login_account_login_et_username"
                            style="@style/login_editText_style"
                            android:hint="@string/login_input_username_hint"/>
                        <ImageView
                            android:id="@+id/login_account_login_iv_clear_username"
                            android:visibility="gone"
                            style="@style/common_clear_input_imageView_style"/>
                    </RelativeLayout>
                    <View
                        style="@style/me_horizontal_view_style"/>
                    <RelativeLayout
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content">
                        <EditText
                            android:id="@+id/login_account_login_et_password"
                            style="@style/login_editText_style"
                            android:inputType="textPassword"
                            android:hint="@string/login_input_password_hint"/>
                        <CheckBox
                            android:id="@+id/login_account_login_checkBox"
                            style="@style/login_checkBox_style"/>
                        <ImageView
                            android:id="@+id/login_account_login_iv_clear_password"
                            android:layout_toLeftOf="@+id/login_account_login_checkBox"
                            android:layout_alignParentRight="false"
                            android:visibility="gone"
                            style="@style/common_clear_input_imageView_style"/>
                    </RelativeLayout>
                    <RelativeLayout
                        android:id="@+id/ll_check_code"
                        android:layout_width="fill_parent"
                        android:layout_height="wrap_content"
                        android:orientation="horizontal"
                        android:visibility="gone" >

                        <View
                            android:layout_width="fill_parent"
                            android:layout_height="1.0dip"
                            android:layout_marginLeft="14.0dip"
                            android:background="#ffdadada" />

                        <EditText
                            android:id="@+id/et_check_code"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_alignParentLeft="true"
                            android:layout_centerVertical="true"
                            android:background="@null"
                            android:hint="@string/login_input_check_code_hint"
                            android:maxWidth="150.0dip"
                            android:padding="16.0dip"
                            android:scrollHorizontally="true"
                            android:singleLine="true"
                            android:textColorHint="@color/gray01"
                            android:textSize="@dimen/size_24" />

                        <ImageView
                            android:id="@+id/iv_check_code"
                            android:layout_width="58.0dip"
                            android:layout_height="30.0dip"
                            android:layout_centerVertical="true"
                            android:layout_gravity="center_vertical"
                            android:layout_marginLeft="5.0dip"
                            android:layout_marginTop="1.0dip"
                            android:layout_toRightOf="@id/et_check_code"
                            android:scaleType="fitXY" />
                    </RelativeLayout>
                </LinearLayout>
                <Button
                    android:id="@+id/login_account_login_btn"
                    style="@style/login_btn_style"/>
                <TextView
                    android:id="@+id/login_account_login_tv_forget_password"
                    style="@style/base_textView_style"
                    android:layout_gravity="right"
                    android:layout_marginTop="@dimen/login_account_login_forget_password_marginTop"
                    android:layout_marginRight="@dimen/login_account_login_forget_password_marginRight"
                    android:drawableRight="@mipmap/yellow_arrow"
                    android:drawablePadding="5dp"
                    android:text="@string/login_account_forget_password"
                    android:textColor="@color/orange"
                    android:textSize="@dimen/login_content_size"/>
            </LinearLayout>

        </LinearLayout>

    </ScrollView>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:padding="10dp"
        android:background="@drawable/white_border_area"
        android:orientation="vertical">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_horizontal"
            android:text="@string/login_bottom_use_third_account"
            android:textSize="@dimen/textSize_16"/>
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="@dimen/login_bottom_icon_layout_marginTop"
            android:gravity="center"
            android:orientation="horizontal">
            <ImageView
                android:id="@+id/login_bottom_iv_qq"
                style="@style/base_imageView_style"
                android:src="@mipmap/ico_qq_accout"/>
            <ImageView
                android:id="@+id/login_bottom_iv_wechat"
                style="@style/base_imageView_style"
                android:layout_marginLeft="@dimen/login_bottom_icon_marginLeft"
                android:src="@mipmap/ico_qq_wixin"/>
            <ImageView
                android:id="@+id/login_bottom_iv_weibo"
                style="@style/base_imageView_style"
                android:layout_marginLeft="@dimen/login_bottom_icon_marginLeft"
                android:src="@mipmap/ico_sina_weibo"/>
            <ImageView
                android:id="@+id/login_bottom_iv_alipay"
                style="@style/base_imageView_style"
                android:layout_marginLeft="@dimen/login_bottom_icon_marginLeft"
                android:src="@mipmap/ico_alipay"
                android:visibility="gone"/>
        </LinearLayout>
    </LinearLayout>

</LinearLayout>

快速登录(获得验证码和登录)

case R.id.login_quick_login_btn_getCode:
    mPhoneNumber = mQuickLoginEtPhoneNumber.getText().toString();
    if (LoginHelperUtil.isPhoneNumber(mPhoneNumber)) {
        BmobManager.getInstance(new BmobMsgSendCallback() {
            @Override
            public void onMsgSendSuccess() {
                ToastUtil.show(LoginActivity.this,R.string.sms_code_send_success);
                //验证码发送成功,倒计时
                setCodeTimeDown();
            }

            @Override
            public void onMsgSendFailure() {
                ToastUtil.show(LoginActivity.this,R.string.sms_code_send_failure);
            }
        }).sendMsgCode(mPhoneNumber);
    } else {
        ToastUtil.show(this,R.string.phone_number_incorrect);
    }
    break;
case R.id.login_quick_login_btn:
    mPhoneNumber = mQuickLoginEtPhoneNumber.getText().toString();
    String code = mQuickLoginEtCode.getText().toString();
    if (LoginHelperUtil.isCodeCorrect(code) && LoginHelperUtil.isPhoneNumber(mPhoneNumber)) {
        BmobManager.getInstance(new BmobLoginCallback() {
            @Override
            public void onLoginSuccess() {
                Log.i(TAG, "onLoginSuccess: 登陆成功");
                ToastUtil.show(LoginActivity.this,R.string.login_success);
            }

            @Override
            public void onLoginFailure() {
                Log.i(TAG, "onLoginFailure: 登陆失败");
                ToastUtil.show(LoginActivity.this,R.string.login_failed);
            }
        }).signOrLoginByMsgCode(mPhoneNumber,code);
    } else {
        ToastUtil.showLong(this,R.string.quick_login_input_incorrect);
    }
    break;

 

账号登录(登录和切换密码明文)

AccountLoginCheckBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
                //切换明密文
                if (checked) {
                    mAccountLoginEtPassword.setTransformationMethod(HideReturnsTransformationMethod.getInstance());
                } else {
                    mAccountLoginEtPassword.setTransformationMethod(PasswordTransformationMethod.getInstance());
                }
                //光标在末尾显示
                mAccountLoginEtPassword.setSelection(mAccountLoginEtPassword.length());
            }
        });

  

 

case R.id.login_account_login_btn:
    String username = mAccountLoginEtUsername.getText().toString();
    String password = mAccountLoginEtPassword.getText().toString();
    if (!TextUtils.isEmpty(username) && !TextUtils.isEmpty(password)) {
        BmobManager.getInstance(new BmobLoginCallback() {
            @Override
            public void onLoginSuccess() {
                ToastUtil.show(LoginActivity.this,R.string.login_success);
                Intent data = new Intent();
                setResult(LOGIN_RESULT_CODE,data);
                finish();
            }
            @Override
            public void onLoginFailure() {
                ToastUtil.show(LoginActivity.this,R.string.login_failed);
            }
        }).login(username,password);
    } else {
        ToastUtil.show(this,R.string.login_input_empty);
    }
    break;

  

 

发表评论
用户名: 匿名