android 简单登陆页面
来源:互联网 发布:阿里云短信接口demo 编辑:程序博客网 时间:2024/06/05 11:17
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:custom="http://schemas.android.com/apk/res-auto" android:layout_width="fill_parent" android:layout_height="fill_parent" android:fitsSystemWindows="true" > <RelativeLayout android:id="@+id/login_layout" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginLeft="20dp" android:layout_marginRight="20dp" android:gravity="center" > <FrameLayout android:id="@+id/username_layout" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginTop="55dp" android:gravity="center" > <EditText android:id="@+id/username" android:layout_width="fill_parent" android:layout_height="@dimen/default_edittext_height" android:layout_marginTop="5dp" android:inputType="number" android:paddingRight="60dp" android:maxLength="20" android:paddingLeft="55dp" > </EditText> <ImageView android:layout_width="22dp" android:layout_height="21dp" android:layout_marginStart="8dp" android:layout_gravity="left|center_vertical" android:background="@drawable/login_usr_in_img" android:visibility="visible" /> <TextView android:id="@+id/contry_sn" android:layout_width="40dp" android:layout_height="50dp" android:layout_gravity="left|center_vertical" android:layout_marginTop="4dp" android:gravity="center" android:text="+62" android:textColor="@android:color/black" android:textSize="18sp" android:visibility="invisible" /> <Button android:id="@+id/bt_username_clear" android:layout_width="23dp" android:layout_height="23dp" android:background="@drawable/button_clear" android:layout_gravity="right|center_vertical" android:layout_marginRight="10dp" android:visibility="invisible" /> </FrameLayout> <FrameLayout android:id="@+id/usercode_layout" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_below="@id/username_layout" android:layout_marginTop="6dp" android:gravity="center" > <EditText android:id="@+id/password" android:layout_width="fill_parent" android:layout_height="@dimen/default_edittext_height" //40 android:inputType="textPassword" android:paddingRight="60dp" android:maxLength="20" android:paddingLeft="55dp" > </EditText> <ImageView android:layout_width="24dp" android:layout_height="22dp" android:layout_marginStart="7dp" android:layout_gravity="left|center_vertical" android:background="@drawable/login_code_in_img" /> <Button android:id="@+id/bt_pwd_eye" android:layout_width="23dp" android:layout_height="23dp" android:background="@drawable/button_eye_n" android:layout_gravity="right|center_vertical" android:layout_marginRight="10dp" /> <Button android:id="@+id/bt_pwd_clear" android:layout_width="23dp" android:layout_height="23dp" android:background="@drawable/button_clear" android:visibility="invisible" android:layout_gravity="right|center_vertical" android:layout_marginRight="33dp" /> </FrameLayout> <Button android:id="@+id/login" android:layout_width="fill_parent" android:layout_height="@dimen/default_button_height" android:layout_below="@id/usercode_layout" android:layout_marginTop="30dp" android:background="#ff336699" android:textColor="@android:color/white" android:gravity="center" android:text="登录" /> <Button android:id="@+id/login_error" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignRight="@id/login" android:layout_below="@id/login" android:background="#00000000" android:text="忘记密码" android:textSize="16sp" /> <Button android:id="@+id/register" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignLeft="@id/login" android:layout_below="@id/login" android:background="#00000000" android:gravity="left|center_vertical" android:text="注册" android:textSize="16sp" android:visibility="visible" /> </RelativeLayout> <RelativeLayout android:id="@+id/remember_layout000" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_marginBottom="1dp" android:layout_marginLeft="20dp" android:layout_marginRight="20dp" > <Button android:id="@+id/registfer" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="#00000000" android:gravity="center" android:singleLine="true" android:text="AnyLife,Make the world a better place." android:textSize="16sp" android:visibility="visible" /> </RelativeLayout></RelativeLayout>
package com.bipbip.activity;import android.content.Intent;import android.os.Bundle;import android.os.Handler;import android.os.Message;import android.text.Editable;import android.text.InputType;import android.text.TextWatcher;import android.view.KeyEvent;import android.view.View;import android.view.View.OnClickListener;import android.view.View.OnLongClickListener;import android.widget.Button;import android.widget.EditText;import android.widget.RelativeLayout;import android.widget.TextView;import android.widget.Toast;import com.bipbip.main.BaseActivity;import com.bipbip.main.MainActivity;import com.bipbip.watch.R;/** * * * 注 册: ValidatePhoneNumActivity --> RegisterActivity * * 忘记密码 ForgetCodeActivity --> RepasswordActivity * * @author liubao.zeng * */ public class LoginActivity extends BaseActivity implements OnClickListener,OnLongClickListener { // 声明控件对象 private EditText et_name, et_pass; private Button mLoginButton,mLoginError,mRegister,ONLYTEST; int selectIndex=1; int tempSelect=selectIndex; boolean isReLogin=false; private int SERVER_FLAG=0; private RelativeLayout countryselect; private TextView coutry_phone_sn, coutryName;//// private String [] coutry_phone_sn_array,coutry_name_array; public final static int LOGIN_ENABLE=0x01; //注册完毕了 public final static int LOGIN_UNABLE=0x02; //注册完毕了 public final static int PASS_ERROR=0x03; //注册完毕了 public final static int NAME_ERROR=0x04; //注册完毕了 final Handler UiMangerHandler = new Handler(){ @Override public void handleMessage(Message msg) { // TODO Auto-generated method stub switch(msg.what){ case LOGIN_ENABLE: mLoginButton.setClickable(true); // mLoginButton.setText(R.string.login); break; case LOGIN_UNABLE: mLoginButton.setClickable(false); break; case PASS_ERROR: break; case NAME_ERROR: break; } super.handleMessage(msg); } }; private Button bt_username_clear; private Button bt_pwd_clear; private Button bt_pwd_eye; private TextWatcher username_watcher; private TextWatcher password_watcher; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);// requestWindowFeature(Window.FEATURE_NO_TITLE); // //不显示系统的标题栏 // getWindow().setFlags( WindowManager.LayoutParams.FLAG_FULLSCREEN,// WindowManager.LayoutParams.FLAG_FULLSCREEN ); setContentView(R.layout.activity_login); et_name = (EditText) findViewById(R.id.username); et_pass = (EditText) findViewById(R.id.password); bt_username_clear = (Button)findViewById(R.id.bt_username_clear); bt_pwd_clear = (Button)findViewById(R.id.bt_pwd_clear); bt_pwd_eye = (Button)findViewById(R.id.bt_pwd_eye); bt_username_clear.setOnClickListener(this); bt_pwd_clear.setOnClickListener(this); bt_pwd_eye.setOnClickListener(this); initWatcher(); et_name.addTextChangedListener(username_watcher); et_pass.addTextChangedListener(password_watcher); mLoginButton = (Button) findViewById(R.id.login); mLoginError = (Button) findViewById(R.id.login_error); mRegister = (Button) findViewById(R.id.register); ONLYTEST = (Button) findViewById(R.id.registfer); ONLYTEST.setOnClickListener(this); ONLYTEST.setOnLongClickListener((OnLongClickListener) this); mLoginButton.setOnClickListener(this); mLoginError.setOnClickListener(this); mRegister.setOnClickListener(this); // countryselect=(RelativeLayout) findViewById(R.id.countryselect_layout);// countryselect.setOnClickListener(this);// coutry_phone_sn=(TextView) findViewById(R.id.contry_sn);// coutryName=(TextView) findViewById(R.id.country_name); // coutryName.setText(coutry_name_array[selectIndex]); //默认为1// coutry_phone_sn.setText("+"+coutry_phone_sn_array[selectIndex]); } /** * 手机号,密码输入控件公用这一个watcher */ private void initWatcher() { username_watcher = new TextWatcher() { public void onTextChanged(CharSequence s, int start, int before, int count) {} public void beforeTextChanged(CharSequence s, int start, int count,int after) {} public void afterTextChanged(Editable s) { et_pass.setText(""); if(s.toString().length()>0){ bt_username_clear.setVisibility(View.VISIBLE); }else{ bt_username_clear.setVisibility(View.INVISIBLE); } } }; password_watcher = new TextWatcher() { public void onTextChanged(CharSequence s, int start, int before, int count) {} public void beforeTextChanged(CharSequence s, int start, int count,int after) {} public void afterTextChanged(Editable s) { if(s.toString().length()>0){ bt_pwd_clear.setVisibility(View.VISIBLE); }else{ bt_pwd_clear.setVisibility(View.INVISIBLE); } } }; } @Override public void onClick(View arg0) { // TODO Auto-generated method stub switch (arg0.getId()) { case R.id.login: //登陆// login(); startActivity(MainActivity.class); break; case R.id.login_error: //无法登陆(忘记密码了吧)// Intent login_error_intent=new Intent();// login_error_intent.setClass(LoginActivity.this, ForgetCodeActivity.class);// startActivity(login_error_intent); break; case R.id.register: //注册新的用户// Intent intent=new Intent();// intent.setClass(LoginActivity.this, ValidatePhoneNumActivity.class);// startActivity(intent); break; case R.id.registfer: if(SERVER_FLAG>10){ Toast.makeText(this, "[内部测试--谨慎操作]", Toast.LENGTH_SHORT).show(); } SERVER_FLAG++; break; case R.id.bt_username_clear: et_name.setText(""); et_pass.setText(""); break; case R.id.bt_pwd_clear: et_pass.setText(""); break; case R.id.bt_pwd_eye: if(et_pass.getInputType() == (InputType.TYPE_CLASS_TEXT|InputType.TYPE_TEXT_VARIATION_PASSWORD)){ bt_pwd_eye.setBackgroundResource(R.drawable.button_eye_s); et_pass.setInputType(InputType.TYPE_CLASS_TEXT|InputType.TYPE_TEXT_VARIATION_NORMAL); }else{ bt_pwd_eye.setBackgroundResource(R.drawable.button_eye_n); et_pass.setInputType(InputType.TYPE_CLASS_TEXT|InputType.TYPE_TEXT_VARIATION_PASSWORD); } et_pass.setSelection(et_pass.getText().toString().length()); break; } } /** * 登陆 */ private void login() { } @Override public boolean onLongClick(View v) { // TODO Auto-generated method stub switch (v.getId()) { case R.id.registfer: if(SERVER_FLAG>9){ } // SERVER_FLAG++; break; } return true; } /** * 监听Back键按下事件,方法2: * 注意: * 返回值表示:是否能完全处理该事件 * 在此处返回false,所以会继续传播该事件. * 在具体项目中此处的返回值视情况而定. */ @Override public boolean onKeyDown(int keyCode, KeyEvent event) { if ((keyCode == KeyEvent.KEYCODE_BACK)) { if(isReLogin){ Intent mHomeIntent = new Intent(Intent.ACTION_MAIN); mHomeIntent.addCategory(Intent.CATEGORY_HOME); mHomeIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); LoginActivity.this.startActivity(mHomeIntent); }else{ LoginActivity.this.finish(); } return false; }else { return super.onKeyDown(keyCode, event); } }}
阅读全文
0 0
- android 简单登陆页面
- 简单登陆页面
- 简单的登陆页面
- Android 登陆页面 记住密码和自动登陆的简单实现
- 简单的实现页面登陆
- Android开发-UI控件:实现登陆页面并跳转和简单的注册页面
- android UI设计:用布局中ayout_weight设置及简单登陆页面
- 简单的JSP用户登陆页面
- 一个简单的登陆页面实现
- 超简单的登陆注册页面实现
- 只用UILabel实现简单登陆页面
- JSP和Servlet简单登陆页面
- 小KING教你做android项目(二)---实现登陆页面并跳转和简单的注册页面
- 小KING教你做android项目(二)---实现登陆页面并跳转和简单的注册页面
- 小KING教你做android项目(二)---实现登陆页面并跳转和简单的注册页面
- Android简单布局------QQ登陆
- Android登陆页面记住密码功能代码
- android 打开google 帐户登陆页面
- ubuntu-16.04.1-server-amd64安装时提示busybox-initramfs软件包错误
- Android中BitmapFactory.Options详解
- ssd为什么比hdd速度要快
- 4. Android工程中使用FFmpeg的so库 -- JNI头文件定义方法的实现
- Linux kernel mail list
- android 简单登陆页面
- HTML基础
- Android Activity生命周期
- 在centos和redhat上安装docker
- 不用加减乘除做加法
- 前端学习手记6/15
- 使用NGINX 来进行反向代理
- mysql in和exists性能比较和使用
- Oracle.补丁.体系结构