<?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 中的进程、线程、协程、同步、异步、回调

    进程和线程究竟是什么东西?传统网络服务模型是如何工作的?协程和线程的关系和区别有哪些?IO过程在什么时间发生? 一.上下文切换技术 简述 在进一步之前,让我们先回顾一下各种上下文切换技术. 不过首先说 ...

  2. ios 同步Get请求的实现

    //第一步,创建URL NSURL *url = [NSURL URLWithString:@"http://itunes.apple.com/search?term=微信&enti ...

  3. 【PRML读书笔记-Chapter1-Introduction】1.3 Model Selection

    在训练集上有个好的效果不见得在测试集中效果就好,因为可能存在过拟合(over-fitting)的问题. 如果训练集的数据质量很好,那我们只需对这些有效数据训练处一堆模型,或者对一个模型给定系列的参数值 ...

  4. 写的一个Sass 和Compass的例子

    /*1.打开项目根目录下的 config.rb 文件 2.搜索 line_comments 关键词,默认应该是 # line_comments = false 3.去掉前面的 #,保存 config. ...

  5. linux常用

    一.命令 1.查指令,man, info, /usr/share/doc/: 2.文档,nano lyp.txt: 3.谁在线,who: 4.数据同步写入硬盘,sync: 5.显示档案,ls: 6.目 ...

  6. django 快速实现注册

    前言 对于web开来说,用户登陆.注册.文件上传等是最基础的功能,针对不同的web框架,相关的文章非常多,但搜索之后发现大多都不具有完整性,对于想学习web开发的新手来说不具有很强的操作性:对于web ...

  7. [python]抽象方法

    抽象方法 我的理解抽象方法就是:父类的一个方法,继承的所有子类都必须要实现这个方法,否则报错. 举例说明 class Base(object): def _method(self): raise No ...

  8. sysbench测试服务器性能

    sysbench目前已经有0.5的版本,不过最普遍使用的依旧是0.4.12,所以接下来我们会以0.4.12这个版本作为测试 Step1:下载安装sysbench wget http://pkgs.fe ...

  9. 基于GTID Replication主从数据不一致操作

    基本的M-S结构   现在master与slave主机数据一致:   mysql> select * from t1; +------+ | id   | +------+ |    1 | | ...

  10. 支付宝支付集成,上传RSA公钥一直显示格式错误

    碰到同样的问题,支付宝的问题,已有解决方案:https://openhome.alipay.com/platform/keyManage.htm?keyType=partner