是男人就下100層【第一層】——高仿微信介面(3)

來源:互聯網
上載者:User

上一篇《是男人就下100層【第一層】——高仿介面(2)》中實現了註冊登入介面,這一篇來看看具體的登入介面實現,先來看看介面效果。


登入介面布局

<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"    android:layout_width="fill_parent"    android:layout_height="fill_parent"    android:background="#eee"    android:orientation="vertical"     android:gravity="center_horizontal">    <RelativeLayout         android:id="@+id/login_top_layout"        android:layout_width="fill_parent"        android:layout_height="45dp"        android:layout_alignParentTop="true"        android:background="@drawable/title_bar">        <Button            android:id="@+id/login_reback_btn"            android:layout_width="70dp"            android:layout_height="wrap_content"            android:layout_centerVertical="true"            android:text="返回"            android:textSize="14sp"            android:textColor="#fff"            android:onClick="login_back"            android:background="@drawable/title_btn_back"/>        <TextView            android:layout_width="wrap_content"            android:layout_height="wrap_content"            android:layout_centerInParent="true"            android:textSize="20sp"            android:textStyle="bold"            android:textColor="#ffffff"            android:text="登入"           />            </RelativeLayout><EditText     android:id="@+id/login_user_edit"    android:layout_width="fill_parent"    android:layout_height="wrap_content"    android:layout_below="@+id/login_top_layout"    android:textColor="#000"    android:textSize="15sp"    android:layout_marginTop="25dp"    android:layout_marginLeft="20dp"    android:layout_marginRight="20dp"    android:singleLine="true"    android:background="@drawable/login_editbox"    android:hint="QQ號/號/手機號(請輸入buaa)"/><EditText     android:id="@+id/login_passwd_edit"    android:layout_width="fill_parent"    android:layout_height="wrap_content"    android:layout_below="@+id/login_user_edit"    android:textColor="#000"    android:textSize="15sp"    android:layout_marginTop="25dp"    android:layout_marginLeft="20dp"    android:layout_marginRight="20dp"    android:background="@drawable/login_editbox"    android:password="true"    android:singleLine="true"    android:hint="密碼(請輸入123)"/><RelativeLayout     android:layout_width="fill_parent"    android:layout_height="wrap_content"    android:layout_marginTop="20dp"    android:layout_below="@+id/login_passwd_edit"    >    <Button        android:id="@+id/forget_passwd"         android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:layout_marginLeft="23dp"        android:layout_marginTop="5dp"        android:text="忘記密碼?"        android:textSize="16sp"        android:textColor="#00f"        android:background="#0000"        android:onClick="login_pw"        />     <Button        android:id="@+id/login_login_btn"        android:layout_width="90dp"        android:layout_height="40dp"        android:layout_marginRight="20dp"        android:layout_alignParentRight="true"        android:text="登入"        android:background="@drawable/btn_style_green"        android:textColor="#ffffff"        android:textSize="18sp"        android:onClick="login_mainweixin"        /></RelativeLayout></RelativeLayout>
在上面的介面中需要注意的是“返回”按鈕的背景資源檔

<?xml version="1.0" encoding="UTF-8"?><selector  xmlns:android="http://schemas.android.com/apk/res/android">    <item android:state_focused="true" android:drawable="@drawable/mm_title_back_focused" />    <item android:state_pressed="true" android:drawable="@drawable/mm_title_back_pressed" />    <item android:state_selected="true" android:drawable="@drawable/mm_title_back_pressed" />    <item android:drawable="@drawable/mm_title_back_normal" /></selector>
上一篇中已經見過,這裡就不囉嗦了

輸入框的背景布局檔案

<?xml version="1.0" encoding="UTF-8"?><selector  xmlns:android="http://schemas.android.com/apk/res/android">    <item android:state_focused="true"  android:drawable="@drawable/login_edit_pressed" />    <item android:state_focused="false" android:state_pressed="true" android:drawable="@drawable/login_edit_pressed" />    <item android:state_focused="false" android:drawable="@drawable/login_edit_normal" /></selector>
按下獲得焦點和失去焦點的背景不同

接下來處理資料校正和跳轉

public void login_mainweixin(View v) {if ("dawanganban".equals(mUser.getText().toString())&& "123456".equals(mPassword.getText().toString())) // 判斷 帳號和密碼{Intent intent = new Intent();intent.setClass(Login.this, LoadActivity.class);startActivity(intent);// Toast.makeText(getApplicationContext(), "登入成功",// Toast.LENGTH_SHORT).show();} else if ("".equals(mUser.getText().toString())|| "".equals(mPassword.getText().toString())) // 判斷 帳號和密碼{new AlertDialog.Builder(Login.this).setIcon(getResources().getDrawable(R.drawable.login_error_icon)).setTitle("登入錯誤").setMessage("帳號或者密碼不可為空,\n請輸入後再登入!").create().show();} else {new AlertDialog.Builder(Login.this).setIcon(getResources().getDrawable(R.drawable.login_error_icon)).setTitle("登入失敗").setMessage("帳號或者密碼不正確,\n請檢查後重新輸入!").create().show();}}
點忘記密碼就不處理了,直接跳到一個頁面吧

public void login_pw(View v) { // 忘記密碼按鈕Uri uri = Uri.parse("http://blog.csdn.net/dawanganban");Intent intent = new Intent(Intent.ACTION_VIEW, uri);startActivity(intent);}
還有一個返回按鈕,直接關閉當前Activity

public void login_back(View v) { // 標題列 返回按鈕this.finish();}
運行結果:

                  


原始碼下載:http://download.csdn.net/detail/lxq_xsyu/6966767

下一篇:http://blog.csdn.net/dawanganban/article/details/20079141


聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.