<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="3dip"
> <!--0固定1可以扩展--> <TableLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:numColumns="8"
android:shrinkColumns="0"
android:stretchColumns="1"> <TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content"> <TextView
android:id="@+id/label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="请输入用户名:" />
<!-- 这个EditText放置在上边id为label的TextView的下边 -->
<EditText
android:id="@+id/username"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/label"
android:background="@android:drawable/editbox_background" /> </TableRow>
<TableRow> <TextView
android:id="@+id/label1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="密码:" />
<!-- 这个EditText放置在上边id为label的TextView的下边 -->
<EditText
android:id="@+id/pass"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/label1"
android:inputType="textPassword"
android:background="@android:drawable/editbox_background" />
<CheckBox
android:id="@+id/checkBox1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="显示密码" /> </TableRow> <TableRow
android:layout_width="wrap_content"
android:layout_height="match_parent">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="确定"
android:id="@+id/ok"
android:layout_column="1"
android:layout_span="1" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="取消"
android:id="@+id/cancel"
android:layout_column="1" /> </TableRow> </TableLayout> </LinearLayout>
package com.example.yanlei.mytk;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.text.method.HideReturnsTransformationMethod;
import android.text.method.PasswordTransformationMethod;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.TextView;
import android.widget.Toast; public class MainActivity extends AppCompatActivity { private TextView passEdit;
private TextView userNameEdit;
private CheckBox checkBox1;
private Button btnok;
private Button btncancel; @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
passEdit = (TextView) findViewById(R.id.pass);
userNameEdit = (TextView) findViewById(R.id.username);
checkBox1 = (CheckBox) findViewById(R.id.checkBox1);
btnok = (Button) findViewById(R.id.ok);
btncancel = (Button) findViewById(R.id.cancel); btncancel.setOnClickListener(new ButtonexitClickListener());
btnok.setOnClickListener(new ButtonokClickListener());
checkBox1.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
// TODO Auto-generated method stub
if (isChecked) {
//如果选中,显示密码
passEdit.setTransformationMethod(HideReturnsTransformationMethod.getInstance());
} else {
//否则隐藏密码
passEdit.setTransformationMethod(PasswordTransformationMethod.getInstance());
} }
}); } private class ButtonexitClickListener implements View.OnClickListener { public void onClick(View v) {
System.exit(0); } } private class ButtonokClickListener implements View.OnClickListener { public void onClick(View v) {
String UserName = userNameEdit.getText().toString();
String pass = passEdit.getText().toString();
Toast toast; if (UserName.equals("YL") && pass.equals("123")) {
toast = Toast.makeText(getApplicationContext(), "密码正确" + UserName + ":" + pass, Toast.LENGTH_LONG); } else {
toast = Toast.makeText(getApplicationContext(), "密码错误" + UserName + ":" + pass, Toast.LENGTH_LONG);
}
toast.show(); } } @Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
} @Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId(); //noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
} return super.onOptionsItemSelected(item);
}
}

优化界面

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="3dip"> <!--0固定1可以扩展--> <TableLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:numColumns="8"
android:shrinkColumns="0"
android:stretchColumns="1"> <TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content"> <TextView
android:id="@+id/label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="请输入用户名:" />
<!-- 这个EditText放置在上边id为label的TextView的下边 -->
<EditText
android:id="@+id/username"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/label"
android:background="@android:drawable/editbox_background" /> </TableRow> <TableRow> <TextView
android:id="@+id/label1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="密码:" />
<!-- 这个EditText放置在上边id为label的TextView的下边 -->
<EditText
android:id="@+id/pass"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/label1"
android:background="@android:drawable/editbox_background"
android:inputType="textPassword" /> <CheckBox
android:id="@+id/checkBox1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="显示密码" /> </TableRow> <TableRow
android:layout_width="wrap_content"
android:layout_height="match_parent"> </TableRow> </TableLayout> <LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="5dip"
android:gravity="right"
android:weightSum="1"> <Button
android:id="@+id/ok"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.20"
android:text="确定"
android:layout_marginRight="20dip" /> <Button
android:id="@+id/cancel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="取消"
android:layout_weight="0.20"
android:hint="退出" android:clickable="true" />
</LinearLayout>
</LinearLayout>

=======================================================

又一个登陆界面

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAlignment="center"
android:text="用户登录界面" android:autoText="false"
android:gravity="center" /> <LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" > <TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="用户名 :" /> <EditText
android:id="@+id/editText1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="请输入用户名" />
</LinearLayout> <LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" > <TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="密 码:" /> <EditText
android:id="@+id/editText2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="请输入密码"
android:layout_weight="1"
android:inputType="textPassword" /> <CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="显示密码" android:id="@+id/checkBox" /> </LinearLayout> <LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" > </LinearLayout> <LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" > <Button
android:id="@+id/btn_confirm"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1" android:text="确认" /> <Button
android:id="@+id/btn_back"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1" android:text="返回" />
</LinearLayout> <ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:id="@+id/imageView"
android:layout_gravity="center_horizontal" /> </LinearLayout>

andriod 用户名和密码的更多相关文章

  1. TortoiseGit:记住用户名和密码

    1.背景: 我们在使用 tortoisegit 工具时会无可避免的经常性 pull 和 push,这时通常要输入用户名和密码,由于麻烦,就有人提出了记住用户名和密码的需求... ... 2.设置: [ ...

  2. git push不用重复输入用户名和密码(解决方案)

    每次git push都要输入用户名和密码,有点麻烦,就上网搜了下解决方案. 网上的解决方案有的讲得不清晰,逐个试了后,总结下两种有效的解决方案.   方案一: 1.在计算机安装盘(即一般为C盘)下找到 ...

  3. c#与JavaScript实现对用户名、密码进行RSA非对称加密

    博主最近手上这个项目呢(就是有上百个万恶的复杂excel需要解析的那个项目,参见博客:http://www.cnblogs.com/csqb-511612371/p/4885930.html),由于是 ...

  4. svn客户端重新设置用户名和密码

    在第一次使用TortoiseSVN从服务器CheckOut的时候,会要求输入用户名和密码,这时输入框下面有个选项是保存认证信息,如果选了这个选项,那么以后就不用每次都输入一遍用户名密码了. 不过,如果 ...

  5. 安装WAMP 及 修改MYSQL用户名 、 密码

    1,下载并安装WAMP 2,启动服务后,找到MYSQL--MYSQL console--弹出命令窗口(刚开始没有初始用户名跟密码,可直接回车执行) 3,首先输入 use mysq;l---然后修改用户 ...

  6. MySQL5.6忘记root用户名和密码

    首先我们要做的是关闭数据库,还好这个只是一个开发库,要是生产库的话使用另外一种方法修改root用户名和密码,我在另一篇文章有记载 然后我们跳过网络,跳过授权表,这个时候只有本机可以登录了,外部机器就不 ...

  7. svn清除已保存的用户名和密码

    在项目中使用SVN是必须的,我们一般将用户名和密码进行保存处理,这样做的好处在于每次都不用输入了,方便快捷.但是当我们想用另外一个svn账号时,这时候该怎么办呢,看下图,让提示框重新出来. 找到这个页 ...

  8. 系统无法开始服务器进程。请检查用户名和密码。 (Exception from HRESULT: 0x8000401A)

    开始-运行-cmd,输入aspnet_regiis.exe -i 重新注册iis 或者 出现以下错误:检索 COM 类工厂中 CLSID 为 {000209FF-0000-0000-C000-0000 ...

  9. TortoiseGit 连接oschina不用每次输入用户名和密码的方法

    每次git clone 和push 都要输入用户名和密码.虽然安全,但在本机上每次都输有些麻烦,如何记住用户名和密码呢? 在网上看了各种方法,太杂,很多可能环境不一样,一直行不通.最后找到一种有效的方 ...

随机推荐

  1. python 字符串编码

    通过字符串的decode和encode方法 1 encode([encoding,[errors]]) #其中encoding可以有多种值,比如gb2312 gbk gb18030 bz2 zlib ...

  2. WEB安全入门(转)

    一. 首先你得了解Web Web分为好几层,一图胜千言:事实是这样的:如果你不了解这些研究对象是不可能搞好安全研究的.这样看来,Web有八层(如果把浏览器也算进去,就九层啦,九阳神功……)!!!每层都 ...

  3. SNF开发平台WinForm之十一-程序打包-SNF快速开发平台3.3-Spring.Net.Framework

    原来我们用的是微软自带的打包工具去打包,但感觉好像也是第三方做的打包并且很是麻烦,还有时不成功报错.那综合考虑就找一个简单实用的打包工具吧,就找到了NSIS这个.具体打包步骤如下: 1.安装NSIS ...

  4. VS2008简体中文正式版序列号-试用到期解决

    VS2008简体中文正式版序列号 VS2008简体中文正式版序列号 1.Visual Studio 2008 Professional Edition:XMQ2Y-4T3V6-XJ48Y-D3K2V- ...

  5. SpringMVC学习系列-后记 结合SpringMVC和Hibernate-validator,根据后台验证规则自动生成前台的js验证代码

    在SpringMVC学习系列(6) 之 数据验证中我们已经学习了如何结合Hibernate-validator进行后台的数据合法性验证,但是通常来说后台验证只是第二道保险,为了更好的用户体验会现在前端 ...

  6. Table_EXISTS_ACTION=APPEND时导入数据时

    11g对数据泵新增了一些功能.这篇介绍新增的选项DATA_OPTIONS=SKIP_CONSTRAINT_ERRORS. Oracle11g的数据泵新增了一个DATA_OPTIONS选项,目前只有一个 ...

  7. [IR] Ranking - top k

    PageRanking 通过: Input degree of link "Flow" model - 流量判断喜好度 传统的方式又是什么呢? Every term在某个doc中的 ...

  8. EPANET能做什么,不能做什么

    What Epanet cand and cannot do Good news!Epanet can do most of the calculations you may need for you ...

  9. 开放产品开发(OPD):产品负责人的工作原则和方法

    月26日我将在2014 WOT全球软件技术峰会做相关的一个主题演讲[产品负责人的工作原则和方法],个原则和相应的一些方法. 以下是本次分享内容: 完整版如下,如果你喜欢想下载的话,点击 http:// ...

  10. [Latex]生成Vertical Timeline

    Vertical TimeLine 用Latex生成一个竖直的VerticalTimeline的想法来源于今天翻看王老师的教师寄语,有感于学院走过的操作系统实验的艰辛之路,遂产生了写一个"小 ...