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)學習服裝設計需要掌握一定的美術功底、理論知識和實踐經驗。以下是一些建議,可以幫助你更好地學習服裝設計:1.建立美術功底:繪畫是服裝設計的基礎,因此需要具備一定的繪畫能力。可以從素描、色彩、速寫等方面入手,進行繪畫訓練。(02)2.學習服裝設計理論:瞭解服裝設計...
-
獨角獸真的存在嗎?獨角獸的十大來歷和傳說
導語:有沒有想過獨角獸是真的?這隻強大的野獸只是個神話嗎?古往今來,有很多人在問世界上真的有獨角獸嗎?獨角獸有什麼特殊含義?之前小編為大家講解過世上有龍的十大證據,接下來呢就為大家揭祕獨角獸的十大來歷和傳說,感興趣的不妨一起往下看!獨角獸的十大來歷和傳...
-
一個比特幣值多少人民幣?2019突破55285元(最高137177元)
導語:比特幣是一種加密的虛擬數字貨幣,在2017年12月17日曾達到歷史最高價19850美元,但是在2017年9月4日,央行表示禁止虛擬貨幣的交易,並且比特幣在中國是沒有法律上的貨幣地位,不過據國外報價表明,在2019年5月14日,比特幣的價格已經再創新高,突破了8000美元,也就是人民幣...
-
李白文明vs歸零者文明 兩者都是什麼樣的存在
導語:李白文明是劉慈欣《詩云》中的一大文明,李白不僅擁有著質能轉換能力,還可以隨意進出十一維,是十分強大的宇宙存在,基本上來說李白文明是真正無視光速維度等等很多宇宙規律的,所以歸零者雖然是三體中的神級文明,但也是明顯比不過李白文明的,今天探祕志就帶大家瞭解...