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學習的個人經驗,歡迎大家持續關注。喜歡的朋友就給投個票吧
-
小規模企業所得稅是什麼
(01)小規模企業所得稅是指適用於符合一定條件的小規模企業的稅收政策。在許多國家,小規模企業享有一些稅收減免或優惠政策,以幫助他們減輕稅負,促進經濟發展。(02)具體小規模企業所得稅政策的適用條件和稅率通常因國家而異。通常情況下,小規模企業所得稅比普通企業所得...
-
ABO血型系統是什麼?血型是按照什麼來劃分的
導語:ABO血型系統是根據紅細胞表面有沒有特別的凝集原A和B來區分血液,最早是由德斯坦納在1900年發現和提出的,主要分爲A、B、AB、O四種血型,假如在紅細胞上只有凝集原A的話就是A型血,如果血型不適合就會引起凝集,從而導致血管堵塞,下面探祕志就帶大家一起看看ABO血型...
-
十大戰鬥力最強恐龍 恐龍中最厲害的第一名是誰
導語:恐龍是一種戰鬥力極強的史前生物,其中最兇猛的就是十大戰鬥力最強恐龍,它們分別是西雅茨龍,南方巨獸龍,諸城暴龍,鯊齒龍,蠻龍,馬普龍,特暴龍,棘龍,滄龍,霸王龍,探祕志帶大家看看吧。1、西雅茨龍第一個上榜十大戰鬥力最強恐龍的是西雅茨龍,這種恐龍主要生活在白堊紀中期...
-
一氧化碳有什麼用途
(01)一氧化碳(CO)是一種有毒氣體,但在某些領域具有重要的用途。以下是一氧化碳的一些主要用途:1.燃料:一氧化碳具有可燃性,可作爲氣體燃料。在冶金工業中,它可以作爲還原劑,用於工業還原氧化鐵(製備鐵)等。2.有機合成:一氧化碳是合成氣和各類煤氣的主要組分,可以用於合成一系...