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

Short video operation: Vlog melee, who can break through?

After posting the video "Going to the Superm...

25 Subtle Flat 2.0 Designs

Today, flat design is not as "flat" as ...

What makes us feel sleepy and what happens if we don't sleep?

Human life is actually very short, and the best y...

Inphic i5 quad-core official in-depth review, the box is also cute

Hello guys! I am back again! Previously, one of ou...

From two perspectives, 13 devilish details in Pinduoduo's mini program sharing

For us e-commerce practitioners, we always feel c...

The victory of "foodies" began when our ancestors learned to cook...

Review expert: Cai Dawei, Professor of the School...