Android App Login Screen

Android App Login Screen

Source code introduction: Simple Android App login interface

Source code effect:

Source code snippet:

  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. }
  71. }

Download address: http://download..com/data/2115241

<<:  Third-party login

>>:  How good is the product manager in a programmer’s dream?

Recommend

Your Android app doesn’t need that many permissions

Android system permissions can be a bit confusing...

It’s better not to eat this kind of melon!

Summer is the time when a lot of fruits are on th...

Why do we like spicy food?

Most of the peppers we talk about now come from f...

How much does it cost to develop a Hezhou housekeeping mini program?

Hezhou housekeeping applet development price 1. D...

Kuaishou Advertising | How to promote on Kuaishou?

Kuaishou advertising is to place advertisements i...

The entire process of event promotion planning is here!

In addition to bringing physical benefits such as...

2020 Tmall Zero-Based Operation Advanced Practical Tutorial

Chapter 1: Jack Taobao Tmall Encyclopedia丨[Introd...