简单登陆UI设计
简单UI设计
作品效果图:


关键技术:
用到了本地化控件:SharedPreferences,简单的说就是本地配置。
四大组件:Intent
基本思路请看代码:
Java代码:
import android.os.Bundle;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.Toast; public class MainActivity extends Activity {
private Button logIn;
private CheckBox rember,auto;
private EditText name,password;
private SharedPreferences test;
private SharedPreferences.Editor editor;
private boolean haved;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main); logIn= (Button) findViewById(R.id.button1);
rember=(CheckBox) findViewById(R.id.remberFlag);
auto=(CheckBox) findViewById(R.id.autoRunFlag);
name=(EditText) findViewById(R.id.name);
password=(EditText) findViewById(R.id.password);
final Intent intent=new Intent(MainActivity.this,NewMainActivity.class);
//打开 或 创建一个名为UserData的xml文件
test=getSharedPreferences("UserData", Context.MODE_PRIVATE);
editor=test.edit(); if(test.getBoolean("auto",false)!=false)
{
startActivity(intent);
} if(test.getBoolean("rember", false)!=false)
{
String temp;
if((temp=test.getString("name", null))!=null)
name.setText(temp);
if((temp=test.getString("password",null)) != null)
password.setText(temp);
rember.setChecked(true);
haved=true;
} logIn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if(haved == false )
{
if(rember.isChecked())
{
editor.putBoolean("rember", true);
editor.putString("name", name.getText().toString());
editor.putString("password", password.getText().toString());
editor.commit();
}
if(auto.isChecked()==true)
editor.putBoolean("auto", true);
}
startActivity(intent);
}
});
}
}
activity_main.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" > <EditText
android:id="@+id/name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/password"
android:layout_alignParentTop="true"
android:layout_marginTop="16dp"
android:ems="10" /> <EditText
android:id="@+id/password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/name"
android:layout_centerHorizontal="true"
android:layout_marginTop="18dp"
android:ems="10" > <requestFocus />
</EditText> <Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/password"
android:layout_below="@+id/password"
android:layout_marginLeft="16dp"
android:text="登陆" /> <CheckBox
android:id="@+id/autoRunFlag"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/password"
android:layout_below="@+id/button1"
android:text="自动登陆" /> <CheckBox
android:id="@+id/remberFlag"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/autoRunFlag"
android:layout_alignBottom="@+id/autoRunFlag"
android:layout_alignRight="@+id/password"
android:text="记住密码" /> </RelativeLayout>
activity_second.xml:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" > <RatingBar
android:id="@+id/ratingBar1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="170dp" /> </RelativeLayout>
AndroidMainifest中要注册:
<activity
android:name="com.example.log_in.NewMainActivity"
android:label="second_activity" >
</activity>
简单登陆UI设计的更多相关文章
- JAVA简单的UI设计
手写代码,还是痛苦点,但对布局有再深入的流程理解, 全IDE会更快速.. package SwingGui.sky.com; import javax.swing.*; import java.awt ...
- UI设计学习路线图
文章转载自「开发者圆桌」一个关于开发者入门.进阶.踩坑的微信公众号 这里整理的UI设计学习路线图包含初中高三个部分,你可以通过百度云盘下载观看对应的视频 链接: http://pan.baidu.co ...
- 摇钱树运营小工具UI设计.vsd
去年,我负责公司的一个互联网投融资平台——摇钱树.系统运营过程中,业务和客服那边不断的反馈一些事情让技术这边协助实现.例如,土豪客户忘记登录密码后懒得自己重置,更愿意选择搭讪客服MM:再比如,客户多次 ...
- UI设计中的48dp定律【转】
有朋友建议我偶尔写写技术类的文章,所以我打算开始穿插性的写一些偏技术方面的科普文章,尽量往小白能看懂的方向写,今天我来讲讲UI设计中的48dp定律. 那么先说说什么是dp ?其实对于一个非技术人员要把 ...
- 2017年8个UI设计流行趋势
设计趋势变化的理由需要考虑各种各样的因素.让我们来一起看看2017年的设计流行趋势吧. 应用界面的设计趋势是不断变化的.随着时间的推移他也在不断的成长,进化.虽然有些趋势还有待检验,但我们还是需要不断 ...
- 【Android UI设计与开发】第05期:引导界面(五)实现应用程序只启动一次引导界面
[Android UI设计与开发]第05期:引导界面(五)实现应用程序只启动一次引导界面 jingqing 发表于 2013-7-11 14:42:02 浏览(229501) 这篇文章算是对整个引导界 ...
- UI设计实战篇——利用Bootstrap框架制作查询页面的界面
Bootstrap框架是一个前端UI设计的框架,它提供了统一的UI界面,简化了设计界面UI的过程(缺点是定制了界面,调整的余地不是太大).尤其是现在的响应时布局(我的理解是页面根据不同的分辨率,采用不 ...
- 教你如何用PS制作多款按钮UI设计教程
教你如何用PS制作多款按钮UI设计教程 本文教大家制作按钮的方法 LV. ★ 初入设计,学做按钮.只会套个底色,加个阴影,字体纯白,小聪明的弄个圆角. LV. ★★(描边.字体.内阴影) 看了很多案例 ...
- 10个必备的移动UI设计资源站(转)
创建移动设计模式是非常重要的一步,记住!这是为移动设备设计而不是web.不仅仅是移动屏幕远小于普通的电脑屏幕,关键是鼠标和键盘已经被手指替代了! 当然还有更重要的,说起来很苦逼,我们再也不能使用一种模 ...
随机推荐
- java-成员变量的属性与成员函数的覆盖
java中在多态的实现是通过类的继承或者接口的实现来完成的. 在类继承或者接口实现过程中就会涉及到成员属性以及成员函数的重写,需要注意的是,成员函数的重写是直接覆盖父类的(继承中),但是成员变量重写是 ...
- [CSS]cursor鼠标样式
用css控制鼠标样式的语法如下: <span style="cursor:*">文本或其它页面元素</span> 把 * 换成如下15个效果的一种: ...
- 深入了解join用法
最近面试经常被问到inner join, right join , left join 今晚决定搞清楚这些: 首先先创建两个表: CREATE TABLE Persons ( Id_P int NO ...
- Android中通过typeface设置字体
Android系统默认支持三种字体,分别为:“sans”, “serif”, “monospace",除此之外还可以使用其他字体文件(*.ttf)方法一:XML中使用android默认字体 ...
- php生成图片验证码
验证码主要用来防止暴力破解的方式来进行登录,下面是php中的图片验证码生成方式,废话不多说,直接上代码 /** * 生成验证码 */ function buildRandomString($type= ...
- WPF扩展标记
标记扩展和 WPF XAML,标记扩展是 XAML 语言以及 XAML 服务的 .NET 实现的常规功能 XAML 处理器和标记扩展 XAML 分析器可将特性值解释为可转换成基元的文本字符串,或可通过 ...
- 用typedef给结构体一个别名
转:typedef 一.用typedef给结构体一个别名 typedef struct tagMyStruct { int iNum; long lLength; } MyStruct; 这语句实际上 ...
- NSURLSession -- 实际开发中运用
NSURLSession实际请求 iOS9使用http请求方法: 在工程info.plist文件内添加NSAppTransportSecurity键,类型为dictionary 在NSAppTrans ...
- python 学习笔记整理
首先自我批评一下,说好的一天写一篇博客,结果不到两天,就没有坚持了,发现自己做什么事情都没有毅力啊!不能持之以恒.但是,这次一定要从写博客开始来改掉自己的一个坏习惯. 可是写博客又该写点什么呢? 反正 ...
- web sql Database
http://www.ibm.com/developerworks/cn/web/1108_zhaifeng_websqldb/ http://baishanheishui.iteye.com/blo ...