简单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设计的更多相关文章

  1. JAVA简单的UI设计

    手写代码,还是痛苦点,但对布局有再深入的流程理解, 全IDE会更快速.. package SwingGui.sky.com; import javax.swing.*; import java.awt ...

  2. UI设计学习路线图

    文章转载自「开发者圆桌」一个关于开发者入门.进阶.踩坑的微信公众号 这里整理的UI设计学习路线图包含初中高三个部分,你可以通过百度云盘下载观看对应的视频 链接: http://pan.baidu.co ...

  3. 摇钱树运营小工具UI设计.vsd

    去年,我负责公司的一个互联网投融资平台——摇钱树.系统运营过程中,业务和客服那边不断的反馈一些事情让技术这边协助实现.例如,土豪客户忘记登录密码后懒得自己重置,更愿意选择搭讪客服MM:再比如,客户多次 ...

  4. UI设计中的48dp定律【转】

    有朋友建议我偶尔写写技术类的文章,所以我打算开始穿插性的写一些偏技术方面的科普文章,尽量往小白能看懂的方向写,今天我来讲讲UI设计中的48dp定律. 那么先说说什么是dp ?其实对于一个非技术人员要把 ...

  5. 2017年8个UI设计流行趋势

    设计趋势变化的理由需要考虑各种各样的因素.让我们来一起看看2017年的设计流行趋势吧. 应用界面的设计趋势是不断变化的.随着时间的推移他也在不断的成长,进化.虽然有些趋势还有待检验,但我们还是需要不断 ...

  6. 【Android UI设计与开发】第05期:引导界面(五)实现应用程序只启动一次引导界面

    [Android UI设计与开发]第05期:引导界面(五)实现应用程序只启动一次引导界面 jingqing 发表于 2013-7-11 14:42:02 浏览(229501) 这篇文章算是对整个引导界 ...

  7. UI设计实战篇——利用Bootstrap框架制作查询页面的界面

    Bootstrap框架是一个前端UI设计的框架,它提供了统一的UI界面,简化了设计界面UI的过程(缺点是定制了界面,调整的余地不是太大).尤其是现在的响应时布局(我的理解是页面根据不同的分辨率,采用不 ...

  8. 教你如何用PS制作多款按钮UI设计教程

    教你如何用PS制作多款按钮UI设计教程 本文教大家制作按钮的方法 LV. ★ 初入设计,学做按钮.只会套个底色,加个阴影,字体纯白,小聪明的弄个圆角. LV. ★★(描边.字体.内阴影) 看了很多案例 ...

  9. 10个必备的移动UI设计资源站(转)

    创建移动设计模式是非常重要的一步,记住!这是为移动设备设计而不是web.不仅仅是移动屏幕远小于普通的电脑屏幕,关键是鼠标和键盘已经被手指替代了! 当然还有更重要的,说起来很苦逼,我们再也不能使用一种模 ...

随机推荐

  1. javascript类继承系列五(其他方式继承)

    除了前面学习的三种继承外,还有另外三种:原型继承寄生继承,寄生组合继承都是以: function object(o) { function F() { } F.prototype = o; retur ...

  2. SQL Server 中WITH (NOLOCK)

    with(nolock)的功能: 1: 指定允许脏读.不发布共享锁来阻止其他事务修改当前事务读取的数据,其他事务设置的排他锁不会阻碍当前事务读取锁定数据.允许脏读可能产生较多的并发操作,但其代价是读取 ...

  3. Maven3(笔记二)

    笔记本二   在Eclipse 中使用Maven 第一节:m2eclipse 插件安装 打开Eclipse,点击菜单Help - > Install New Software 点击Add 按钮N ...

  4. c# ADO连接Access 执行Open后程序自动退出

    今天利用ADO连接Access数据库的时候遇到了前所未见的问题,Access数据库连接串,OleDbConnection,open的时候,系统就会自动关闭所有调试. 我就很纠结了,这个AccessHe ...

  5. 判断ios是app第一次启动

    首次运行的应用程序加入一些help 或者 宣传动画 现在变的很重要了. 一个有用的例子是发送一个分析实例.这可能是一个很好的方法来确定有多少人下载实用应用程序.有人会说:“但是,嘿,苹果AppStor ...

  6. js 保留小数位数

    eg: var num=3.1415926 小数位处理:num.toFixed(n)      n:小数位数

  7. 关于反射Assembly.Load("程序集").CreateInstance("命名空间.类")

    关于反射Assembly.Load("程序集").CreateInstance("命名空间.类") 而不管在哪一层写这段代码其中的("程序集" ...

  8. 【小结】有关mysql扩展库和mysqli扩展库的crud操作封装

    现阶段php如果要操作mysql数据库 php给我们提供了3套库 1.mysql扩展库   面向过程操作 2.mysqli扩展库  面向对象操作和面向过程操作并存  安全性和效率高于mysql扩展库 ...

  9. Android中用Application类实现全局变量

    最近在项目中,遇到了application这个类,开始不知道有什么用,经过学习后才知道它的用途也蛮大的,举个例子,如果想在整个应用中使用全局变量,在java中一般是使用静态变量,public类型:而在 ...

  10. shell 1变量注意点

    定义变量时,变量名不加美元符号($),如: variableName="value" 注意,变量名和等号之间不能有空格,这可能和你熟悉的所有编程语言都不一样. 删除变量 使用 un ...