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

New trends in ASO optimization in 2016!

The bell of 2016 has rung. Looking back on 2015, ...

User growth fission guide!

Fission is a standard feature for user growth and...

Super practical! Let’s talk about icon design process and tips

Icon design requires proficiency in the use of so...

As catastrophic tipping points approach, how should humanity respond?

The vicious cycle of catastrophic climate change ...

Facebook enters live video streaming. Will live streaming become a new trend?

Apple held its autumn new product launch conferen...

Some Apple iPhone 13/12 iOS 15 devices damage car Bluetooth hands-free system

According to 9to5 Mac, more and more iPhone users...

How WeChat makes 44 yuan per user

[[152805]] Data from market research firm Activat...

Is Toutiao worth $10 billion?

There have been a lot of debates about Toutiao...