- 浏览: 8027 次
- 性别:
文章分类
最新评论
package com.gcntc.news_editing_offline.ui;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import com.gcntc.news_editing_offline.R;
public class Login extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.login);
Button button=(Button)findViewById(R.id.button1);
button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
String user=((EditText)findViewById(R.id.editText1)).getText().toString();
String pwd=((EditText)findViewById(R.id.editText2)).getText().toString();
user=pwd="admin";
boolean flag=false;
for(int i=0;i<Data.USER.length;i++){
if(user.equals(Data.USER[i][0])){
if(pwd.equals(Data.USER[i][1])){
flag=true;
break;
}
}
}
if(flag){
Intent intent = new Intent(Login.this, MainActivity.class);
startActivity(intent);
}else{
Toast.makeText(Login.this, "用户名或密码错误!", Toast.LENGTH_SHORT).show();
}
}
});
}
}
xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@drawable/welcome_bg" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_above="@+id/editText1"
android:layout_marginBottom="20dp"
android:src="@drawable/welcome_app_icon" />
<EditText
android:id="@+id/editText1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_centerHorizontal="true"
android:layout_above="@+id/editText2"
android:layout_marginTop="5dp"
android:ems="10"
android:textColorHint="@color/gray"
android:hint="用户名"
android:text="admin">
<requestFocus />
</EditText>
<EditText
android:id="@+id/editText2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_centerInParent="true"
android:ems="10"
android:hint="密码"
android:textColorHint="@color/gray"
android:inputType="textPassword"
android:text="admin"/>
<Button
android:id="@+id/button1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_below="@+id/editText2"
android:layout_alignLeft="@id/editText2"
android:layout_alignRight="@id/editText2"
android:layout_marginTop="5dp"
android:background="@drawable/btn_login"
android:text="登录"
android:textColor="@color/white"
/>
</RelativeLayout>
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import com.gcntc.news_editing_offline.R;
public class Login extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.login);
Button button=(Button)findViewById(R.id.button1);
button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
String user=((EditText)findViewById(R.id.editText1)).getText().toString();
String pwd=((EditText)findViewById(R.id.editText2)).getText().toString();
user=pwd="admin";
boolean flag=false;
for(int i=0;i<Data.USER.length;i++){
if(user.equals(Data.USER[i][0])){
if(pwd.equals(Data.USER[i][1])){
flag=true;
break;
}
}
}
if(flag){
Intent intent = new Intent(Login.this, MainActivity.class);
startActivity(intent);
}else{
Toast.makeText(Login.this, "用户名或密码错误!", Toast.LENGTH_SHORT).show();
}
}
});
}
}
xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@drawable/welcome_bg" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_above="@+id/editText1"
android:layout_marginBottom="20dp"
android:src="@drawable/welcome_app_icon" />
<EditText
android:id="@+id/editText1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_centerHorizontal="true"
android:layout_above="@+id/editText2"
android:layout_marginTop="5dp"
android:ems="10"
android:textColorHint="@color/gray"
android:hint="用户名"
android:text="admin">
<requestFocus />
</EditText>
<EditText
android:id="@+id/editText2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_centerInParent="true"
android:ems="10"
android:hint="密码"
android:textColorHint="@color/gray"
android:inputType="textPassword"
android:text="admin"/>
<Button
android:id="@+id/button1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_below="@+id/editText2"
android:layout_alignLeft="@id/editText2"
android:layout_alignRight="@id/editText2"
android:layout_marginTop="5dp"
android:background="@drawable/btn_login"
android:text="登录"
android:textColor="@color/white"
/>
</RelativeLayout>
发表评论
-
GestureDetector类及其用法
2014-09-02 14:41 0当用户触摸屏幕的 ... -
信鸽demo
2014-07-07 10:12 0DBOpenHelper package com.exam ... -
几种listitem griditem
2014-06-25 14:18 0<ListView and ... -
title上左右按钮
2014-06-25 13:33 305<RelativeLayout andr ... -
理财dome
2014-06-13 17:07 0带SQlite的项目 数据模型公共类 包名.model 收入信 ... -
选项卡片段
2014-06-10 14:34 404主界面的XML <TabHost xmlns:and ... -
Galley
2014-06-10 13:45 0Java源代码 public class Chapter7 ... -
GridView
2014-06-10 13:10 0例子一:继承ArrayAdapter作为自定义adapter ... -
Spinner
2014-06-10 10:33 0设置Spinner之中的元素内容,采用了ArrayAdapte ... -
ListView继承ListActivity来实现
2014-06-10 10:10 0ListActivity是一个全屏的list,如果我们需要定制 ... -
文件管理器(草稿篇)
2014-06-06 10:23 997package com.example.wenjiangu ... -
手机通讯录
2014-06-06 10:05 380仅导出手机联系人 package com.example. ... -
发送手机号获取验证码
2014-06-06 09:03 0输入手机号 package com.example.boh ... -
照片缩放和缩略图
2014-06-06 08:41 806java private Bitmap comp(Bit ... -
获取自定义提示转轮
2014-06-03 10:21 400java LayoutInflater inflater = ... -
修改密码
2014-06-03 10:14 315bc_Button=(Button)findViewById( ... -
EditText边框
2014-06-03 10:07 490drawable my_edittext.xml <?x ... -
欢迎界面
2014-06-03 09:58 388package com.gcntc.news_editing_ ...
相关推荐
仿QQ登陆界面 仿QQ登陆界面 仿QQ登陆界面 仿QQ登陆界面
非常好的登陆界面,android开发,记住密码
MFC的登陆界面MFC的登陆界面MFC的登陆界面MFC的登陆界面
Excelvba 登陆界面 包含代码
EAS 登陆界面的修改,例如登陆界面图片 logo 等之类的更改
在老师讲过之后,自己编写的一个简单的登陆界面 利用C++设置的简单登陆界面
自制简易qq登陆界面,第一次制作页面,写的有很多不足的地方,适合初学者看
很好的登陆界面编制的程序,完全是用Visual C++ 编制的哦!
漂亮的登陆界面,适合所以的登陆,很容易修改
微信小程序登陆界面,输入账号密码即跳转到另一页面,亲测可用
labview 登陆界面设计。 labview 用户登陆界面设计,包括用户管理,可增减用户 labview 登陆界面
sqlite 安卓 登陆界面
Java登陆界面代码(可以用,界面带照片) 文档标签 JAVA(34664) java(34664) JPanel(207) public(36533) void(25782) import(7523) class(36042) LoginIn(3) JButton(274) Label(4835) java登陆界面代码,一个...
C# web编程,登陆界面代码,判断用户是否已登录。
该文件是一段在MVC框架下实现的登陆界面,有连接数据库功能,还有特色的样式,动态的背景,验证码认证。总之,对于初学者来说很不错。
简单的登陆界面,可以注册用户信息并登陆修改信息
这是一个已具有随机验证码,通过CSS等控制,画面显得美观雅致而且适用多个项目的登陆界面,登陆界面项目名称可随意更改。
登陆界面-漂亮的登录界面 纯自己写的,仅供大家参考咧咧
登陆界面登陆界面登陆界面登陆界面登陆界面登陆界面登陆界面登陆界面
易语言源码易语言自绘登陆界面源码.rar 易语言源码易语言自绘登陆界面源码.rar 易语言源码易语言自绘登陆界面源码.rar 易语言源码易语言自绘登陆界面源码.rar 易语言源码易语言自绘登陆界面源码.rar 易语言源码...