Android開發學習:[11]仿QQ登錄界面
操作方法
(01)首先我們打開Android Studio然後再編寫登錄界面代碼如下:<?xml version="1.0" encoding="utf-8"?><TableLayout android:id="@+id/tableLayout1"android:layout_width="fill_parent"android:layout_height="fill_parent"xmlns:android=""android:gravity="center_vertical"android:stretchColumns="0,3"><!-- 第一行 --><TableRow android:id="@+id/tableRow1"android:layout_width="wrap_content"android:layout_height="wrap_content"><TextView/><TextView android:text="帳 號:"android:id="@+id/textView1"android:layout_width="wrap_content"android:textSize="24px"android:layout_height="wrap_content"/><EditText android:id="@+id/editText1"android:textSize="24px"android:layout_width="wrap_content"android:layout_height="wrap_content" android:minWidth="200px"/><TextView /></TableRow><!-- 第二行 --><TableRow android:id="@+id/tableRow2"android:layout_width="wrap_content"android:layout_height="wrap_content"><TextView/><TextView android:text="密 碼:"android:id="@+id/textView2"android:textSize="24px"android:layout_width="wrap_content"android:layout_height="wrap_content"/><EditText android:layout_height="wrap_content"android:layout_width="wrap_content"android:textSize="24px"android:id="@+id/editText2"android:inputType="textPassword"/><TextView /></TableRow><!-- 第3行 --><TableRow android:id="@+id/tableRow3"android:layout_width="wrap_content"android:layout_height="wrap_content"><TextView/><Button android:text="登錄"android:id="@+id/login"android:layout_width="wrap_content"android:layout_height="wrap_content"/><Button android:text="退出"android:id="@+id/exit"android:layout_width="wrap_content"android:layout_height="wrap_content"/><TextView /></TableRow></TableLayout>
(02)然後我們編寫登錄成功的QQ界面代碼(簡易版):<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android=""android:id="@+id/linearLayout1"android:orientation="vertical"android:layout_width="fill_parent"android:layout_height="fill_parent" ><LinearLayoutandroid:id="@+id/linearLayout2"android:orientation="horizontal"android:layout_width="match_parent"android:layout_height="wrap_content" ><TextViewandroid:id="@+id/nickname"android:layout_width="wrap_content"android:layout_weight="9"android:textSize="24px"android:padding="20px"android:layout_height="wrap_content"android:text="TextView" /><Buttonandroid:id="@+id/m_exit"android:layout_weight="1"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="退出登錄" /></LinearLayout><ListViewandroid:id="@+id/listView1"android:entries="@array/option"android:layout_width="match_parent"android:layout_height="wrap_content" ></ListView></LinearLayout>
(03)然後我們編寫登入的賬號驗證代碼:一、編寫一個final類,用於保存用戶信息:package ersutil;/*** Created by asus on 2015/1/29 0029.*/public final class Data {public static String[][]USERS={{"0001","123456","basillee"},{"0002","123456","basillee2"},{"0003","123456","basillee3"}};}
(04)然後我們編寫驗證用戶輸入的賬號密碼,並且實現跳轉到狀態頁面:private void testImitateQQ(){Button login=(Button)findViewById(n);Button exit=(Button)findViewById();nClickListener(new ickListener() {@Overridepublic void onClick(View v) {String number=((EditText)findViewById(Text1))ext()ring();String password=((EditText)findViewById(Text2))ext()ring();boolean flag=false;String nickName="";for(int i=0;i< th;i++){if(ls(S[i][0])){if(ls(S[i][1])){nickName=S[i][2];flag=true;break;}}}if(flag){Intent intent=new Intent(,s);Bundle bundle=new Bundle();tring("nickName",nickName);xtras(bundle);startActivity(intent);}else{Text(getApplicationContext(),"wrong account or password",TH_LONG)();}}});nClickListener(new ickListener() {@Overridepublic void onClick(View v) {finish();}});}
(05)然後我們編寫QQ登錄之後的狀態頁面,接受登錄頁面傳來的用戶名並且顯示:Button button=(Button)findViewById(.m_exit);nClickListener(new ickListener() {@Overridepublic void onClick(View v) {finish();}});Intent intent=getIntent();Bundle bundle=xtras();String nickName=tring("nickName");TextView textView=(TextView)findViewById(name);ext("User:"+nickName);
(06)然後我們可以點擊運行測試程序,程序運行如下:
(07)後面將繼續更新Android學習的個人經驗,歡迎大家持續關注。喜歡的朋友就給投個票吧
-
猴子智力相當於人幾歲?揭祕猴子的十大聰明之處
導語:猴子作爲一種十分討人喜歡和大腦發達的哺乳類動物,你們對其瞭解多少呢?之前小編爲大家講解過世界上最大的猴子,下面就爲大家揭祕猴子的十大聰明之處,感興趣的趕緊一起往下看吧!猴子的十大聰明之處1、猴子的智商一般相當於人類的3~4歲,但是有些特別聰明的,智商可...
-
沒身份證怎麼坐高鐵
(01)如果您沒有身份證,您仍然可以乘坐高鐵,但需要提供其他真實、準確的有效身份證件信息或複印件。以下是一些可以替代身份證的證件:1.臨時身份證明:如果您在購票或乘車前因有效身份證件未攜帶、丟失等原因無法出示有效證件,您可以至車站鐵路公安制證口辦理乘坐旅客列...
-
菠蘿蜜粘液的去除技巧
(01)您好!菠蘿蜜粘液的去除技巧有很多,以下是一些常見的方法:1.使用鹽:將適量的食用鹽倒在菠蘿蜜粘液的區域上,然後用乾淨的抹布或紙巾擦拭即可。(02)2.使用醋或檸檬汁:將醋或檸檬汁倒在菠蘿蜜粘液的區域上,靜置幾分鐘後用抹布或紙巾擦拭即可。3.使用洗潔精:將洗潔精倒在菠...
-
繡球菌怎麼吃
(01)繡球菌(Hydrangeamacrophylla)是一種觀賞植物,花朵多爲藍色或粉紅色,常用於裝飾和花束製作。然而,繡球菌並不適合食用,因爲其花朵和其他部分可能對人體有毒。(02)以下是關於繡球菌的一些詳細信息:1.毒性:繡球菌含有所謂的花青素,主要存在於花朵和葉子中。花青素可能對人...