andriod 用户名和密码
- <?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 用户名和密码的更多相关文章
- TortoiseGit:记住用户名和密码
1.背景: 我们在使用 tortoisegit 工具时会无可避免的经常性 pull 和 push,这时通常要输入用户名和密码,由于麻烦,就有人提出了记住用户名和密码的需求... ... 2.设置: [ ...
- git push不用重复输入用户名和密码(解决方案)
每次git push都要输入用户名和密码,有点麻烦,就上网搜了下解决方案. 网上的解决方案有的讲得不清晰,逐个试了后,总结下两种有效的解决方案. 方案一: 1.在计算机安装盘(即一般为C盘)下找到 ...
- c#与JavaScript实现对用户名、密码进行RSA非对称加密
博主最近手上这个项目呢(就是有上百个万恶的复杂excel需要解析的那个项目,参见博客:http://www.cnblogs.com/csqb-511612371/p/4885930.html),由于是 ...
- svn客户端重新设置用户名和密码
在第一次使用TortoiseSVN从服务器CheckOut的时候,会要求输入用户名和密码,这时输入框下面有个选项是保存认证信息,如果选了这个选项,那么以后就不用每次都输入一遍用户名密码了. 不过,如果 ...
- 安装WAMP 及 修改MYSQL用户名 、 密码
1,下载并安装WAMP 2,启动服务后,找到MYSQL--MYSQL console--弹出命令窗口(刚开始没有初始用户名跟密码,可直接回车执行) 3,首先输入 use mysq;l---然后修改用户 ...
- MySQL5.6忘记root用户名和密码
首先我们要做的是关闭数据库,还好这个只是一个开发库,要是生产库的话使用另外一种方法修改root用户名和密码,我在另一篇文章有记载 然后我们跳过网络,跳过授权表,这个时候只有本机可以登录了,外部机器就不 ...
- svn清除已保存的用户名和密码
在项目中使用SVN是必须的,我们一般将用户名和密码进行保存处理,这样做的好处在于每次都不用输入了,方便快捷.但是当我们想用另外一个svn账号时,这时候该怎么办呢,看下图,让提示框重新出来. 找到这个页 ...
- 系统无法开始服务器进程。请检查用户名和密码。 (Exception from HRESULT: 0x8000401A)
开始-运行-cmd,输入aspnet_regiis.exe -i 重新注册iis 或者 出现以下错误:检索 COM 类工厂中 CLSID 为 {000209FF-0000-0000-C000-0000 ...
- TortoiseGit 连接oschina不用每次输入用户名和密码的方法
每次git clone 和push 都要输入用户名和密码.虽然安全,但在本机上每次都输有些麻烦,如何记住用户名和密码呢? 在网上看了各种方法,太杂,很多可能环境不一样,一直行不通.最后找到一种有效的方 ...
随机推荐
- drupal7 Views Bulk Operations (VBO)
介绍 drupal通常用views制作列表,列表也应该能实现某些操作,例如删除.审批等,并且应该是批量进行的,VBO的存在就是为了实现views批量操作功能.事实上,drupal把操作统称为actio ...
- Android代码截屏
本文来源:http://myhpu2008.iteye.com/blog/999779 这种方法应该只能对当前Activity本身进行截屏,因而你只能在你应用程序中参照该代码对其应用程序本身截屏. i ...
- php分页类代码带分页样式效果(转)
php分页类代码,有漂亮的分页样式风格 时间:2016-03-16 09:16:03来源:网络 导读:不错的php分页类代码,将类文件与分页样式嵌入,实现php查询结果的精美分页,对研究php分页原理 ...
- base.js
function $_id(id){return document.getElementById(id)};//$只定义为通过ID返回元素的功能 //-----------------------do ...
- Mac OS使用ll、la、l等ls的别名命令
在linux下习惯使用ll.la.l等ls别名的童鞋到mac os可就郁闷了-- 其实只要在用户目录下建立一个脚本“.bash_profile”,并输入以下内容即可: alias ll='ls -al ...
- Windows上使用clang编译
- 先自己从源代码 (http://llvm.org/releases/) 编译llvm和clang,或者直接安装clang for Windows - 测试过使用cygwin (https://cy ...
- storm分组模式
Shuffle grouping: Tuples被随机分配到每一个bolt’s task,以便于每一个bolt’s task获得相同数量的tuples. Fields grouping: Stream ...
- Communication - 03.RILC
RIL层的作用大体上就是将上层的命令转换成相应的AT指令,控制modem工作.生产modem的厂家有很多:Qualcomm, STE, Infineon... 不同的厂家都有各自的特点,当然也会有各自 ...
- gulp-notify处理报错----gulp系列(二)
上一节,以less为例,入门了gulp,并为任务结构做了抽离. 前端们,gulp该用起来了,简单的demo入门——gulp系列(一) 本节学习下gulp-notify,官方这样解释的: gulp-no ...
- 开源一个基于天天团购的团购app
可能大家都知道天天团购开源系统,一个做团购的开源项目很赞,前些日子做了基于天天团购系统做的团购客户端和移动端服务器!源代码放出,有了解的可以看看,希望收益! 先说服务器:app的服务器,基于天天团购的 ...