Android App 登录界面

移动开发
简单的Android App 登录界面

源码简介:简单的Android App 登录界面

源码效果:

源码片段:

  1. public class LoginActivity extends ActionBarActivity { 
  2.   
  3.     private Context context; 
  4.   
  5.     @Override 
  6.     protected void onCreate(Bundle savedInstanceState) { 
  7.         super.onCreate(savedInstanceState); 
  8.         setContentView(R.layout.activity_login); 
  9.   
  10.         context = getApplicationContext(); 
  11.   
  12.         createLogo(); 
  13.         createToast(R.id.tvNext, "Next"); 
  14.         createToast(R.id.tvSignup, "Sign Up"); 
  15.         createToast(R.id.tvPolicy, "Privacy Policy"); 
  16.         createToast(R.id.tvForgot, "Forgot Password, huh?"); 
  17.         createLoginEvent(); 
  18.     } 
  19.   
  20.     private void createLogo(){ 
  21.         Typeface vibeFont = Typeface.createFromAsset(getAssets(), "fonts/GreatVibes-Regular.otf"); 
  22.         TextView tvLogo = (TextView) findViewById(R.id.tvLogo); 
  23.         tvLogo.setTypeface(vibeFont); 
  24.     } 
  25.   
  26.     private void createToast(int viewId, final String text){ 
  27.         TextView view = (TextView) findViewById(viewId); 
  28.         view.setOnClickListener(new View.OnClickListener() { 
  29.             @Override 
  30.             public void onClick(View v) { 
  31.                 Toast.makeText(context, text, Toast.LENGTH_SHORT).show(); 
  32.             } 
  33.         }); 
  34.     } 
  35.   
  36.     private void createLoginEvent(){ 
  37.         EditText etPassword = (EditText) findViewById(R.id.etPassword); 
  38.         etPassword.setOnKeyListener(new View.OnKeyListener() { 
  39.             @Override 
  40.             public boolean onKey(View v, int keyCode, KeyEvent event) { 
  41.                 if (keyCode == KeyEvent.KEYCODE_ENTER) { 
  42.                     Toast.makeText(context, "Logging in..", Toast.LENGTH_SHORT).show(); 
  43.                 } 
  44.                 return false
  45.             } 
  46.         }); 
  47.     } 
  48.   
  49.   
  50.     @Override 
  51.     public boolean onCreateOptionsMenu(Menu menu) { 
  52.         // Inflate the menu; this adds items to the action bar if it is present. 
  53.         getMenuInflater().inflate(R.menu.menu_login, menu); 
  54.         return true
  55.     } 
  56.   
  57.     @Override 
  58.     public boolean onOptionsItemSelected(MenuItem item) { 
  59.         // Handle action bar item clicks here. The action bar will 
  60.         // automatically handle clicks on the Home/Up button, so long 
  61.         // as you specify a parent activity in AndroidManifest.xml. 
  62.         int id = item.getItemId(); 
  63.   
  64.         //noinspection SimplifiableIfStatement 
  65.         if (id == R.id.action_settings) { 
  66.             return true
  67.         } 
  68.   
  69.         return super.onOptionsItemSelected(item); 
  70.     } 

下载地址:http://down.51cto.com/data/2115241

责任编辑:倪明 来源: devstore
相关推荐

2019-10-11 19:04:23

APP界面布局导航

2023-05-19 19:35:11

ChatGPT数据泄露

2015-10-13 09:15:18

App登录模块设计

2011-09-01 10:21:18

ubuntugdm

2015-08-12 16:12:15

Windows 10登录

2019-07-08 14:33:25

资讯类APPAPP界面设计

2011-07-14 15:28:28

Ubuntu 11.1

2017-08-03 14:50:53

Windows 10Windows登录界面

2015-08-28 09:40:39

自动登录webapp

2013-05-28 14:39:25

Android开发Android App

2018-11-29 11:12:33

UbuntuGDM界面背景

2016-10-14 08:45:19

Windows 10隐藏密码

2011-06-21 14:12:14

Qt Linux 登录界面

2013-03-18 09:58:58

Windows 8

2009-02-17 23:51:57

Linux程序登录界面

2011-08-19 15:42:39

win7登陆界面ogo信息

2009-06-23 08:39:01

微软Windows 7操作系统

2011-12-20 10:42:22

Android应用界面设计

2014-08-21 10:14:09

APP界面设计移动客户端

2009-11-12 08:50:10

Windows 7登陆界面更换
点赞
收藏

51CTO技术栈公众号