简单登陆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.不仅仅是移动屏幕远小于普通的电脑屏幕,关键是鼠标和键盘已经被手指替代了! 当然还有更重要的,说起来很苦逼,我们再也不能使用一种模 ...
随机推荐
- js -去掉首尾的空格.
function trimFE (str) { return str.replace(/^\s\s*/, '').replace(/\s\s*$/, ''); }
- MySQL使用指南(上)
作者:大金刚 有很多朋友虽然安装好了mysql但却不知如何使用它.在这篇文章中我们就从连接MYSQL.修改密码.增加用户等方面来学习一些MYSQL的常用命令. 一.连接MYSQL. 格式: mys ...
- java获取远程网络图片文件流、压缩保存到本地
1.获取远程网路的图片 /** * 根据地址获得数据的字节流 * * @param strUrl * 网络连接地址 * @return */ public static byte[] getImage ...
- Qt程序开机启动的怪现象————无法正常显示程序皮肤
事情很简单:最近公司项目在做即时通讯软件,类似QQ.该软件应该支持开机启动这样的常用功能.但是实际上开发该功能的时候碰到了个问题:开机启动程序无法正常加载皮肤文件. 这个问题让我头疼了很久啊.最终确定 ...
- 用3种方法在 operator= 中处理“自我赋值”
假设你建立一个class 用来保存一个指针指向一块动态分配的位图. class Bitmap {......}; class Widget{ ... private: Bitmap* pb ; }; ...
- ubuntu 14.04 修改PS1提示符
默认情况下,Ubuntu终端会输出完整路径,在路径名很长的时候,提示方式很不友好,通过以下步骤修改PS1变量的设置,可以让终端输出相对路径.类似于红帽系统的风格.修改思路:将w修改为W显示绝对路径,并 ...
- 关于C#的那点事........
起源 C#(读做C-sharp)编程语言是由微软公司的Anders Hejlsberg和 Scott Willamette领导的开发小组专门为.NET平台设计的语言,它可以使程序员移植到.NET上.这 ...
- WPF DataGrid 行头小三角
<DataTemplate x:Key="RowHeaderTemplate"> <StackPanel Orientation="Horizontal ...
- Python疑问系列
最近在看python源码 ------点点滴滴做个记录. 预计要分的系列: 1. import 分析 2. 主要bytecode 分析 3. python启动分析 4. object对象分析 最后希望 ...
- 自动生成makefile的脚本
如果需要测试某一个特性,写了一个test.cpp 某天又增加了一个utils.cpp,依此类推,测试文件越来越多 每次测试时都要手动维护一个makefile实在是不明智的 于是萌生了用脚本自动维护的念 ...