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美元,也就是人民币...
-
酒能寄快递吗
(01)酒在寄快递方面需要考虑以下因素:1.国家法律法规:不同国家对于寄送酒类的规定存在差异,一些国家可能允许寄送酒类,但也有些国家可能禁止或限制寄送酒类。(02)在寄送酒类之前,需要先了解目的地国家的法律法规和邮寄政策。2.邮寄公司政策:邮寄公司通常有自己的规定和限...