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

Earphones may make Apple the king of wearables

I ran down the subway station stairs, thinking I ...

Three unfavorable factors: Where is Samsung's chance to redeem itself?

Samsung, whose founder is in poor health, may hav...

A set of logic that may be suitable for all new media to increase followers!

Output makes people grow, output makes people gro...

How to operate a good community?

There are so many communities, which ones make yo...

OKR: Organizational Agile Goals and Performance Management

OKR: Organizational Agile Goals and Performance M...

Use this trick well and your user conversion rate will increase exponentially!

Let me tell you a story first: Smart little begga...

A weird physics puzzle of a cat falling from a height

© WGBH Leviathan Press: Several years ago, I hear...

Traditional SIM cards: It’s time to say goodbye

Key Points The existence of SIM cards has partial...

A "golden seed" creates a "bountiful" scene for beer and wheat!

"The yield per mu is 767.5 kg! This is a new...