学习交流

当前位置 /首页/母婴教育/学习交流/列表

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>

Android开发学习:[11]仿QQ登录界面

(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>

Android开发学习:[11]仿QQ登录界面 第2张

(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"}};}

Android开发学习:[11]仿QQ登录界面 第3张

(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();}});}

Android开发学习:[11]仿QQ登录界面 第4张

(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);

Android开发学习:[11]仿QQ登录界面 第5张

(06)然后我们可以点击运行测试程序,程序运行如下:

Android开发学习:[11]仿QQ登录界面 第6张
Android开发学习:[11]仿QQ登录界面 第7张

(07)后面将继续更新Android学习的个人经验,欢迎大家持续关注。喜欢的朋友就给投个票吧

TAG标签:Android QQ 界面 登录 学习 #