Advertisement
Guest User

Login.java

a guest
Sep 16th, 2014
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.56 KB | None | 0 0
  1. //For Login.java
  2. package com.mark.uricacidevaluator;
  3.  
  4. import android.support.v7.app.ActionBarActivity;
  5. import android.os.Bundle;
  6. import android.content.Intent;
  7. import android.view.Menu;
  8. import android.view.MenuItem;
  9. import android.view.View;
  10. import android.widget.Button;
  11. import android.widget.EditText;
  12. import android.widget.Toast;
  13.  
  14. public class Login extends ActionBarActivity {
  15. Button login,newuser;
  16. EditText uname,pword;
  17. SqliteController handler;
  18.  
  19. @Override
  20. protected void onCreate(Bundle savedInstanceState) {
  21. super.onCreate(savedInstanceState);
  22. setContentView(R.layout.login);
  23. login = (Button)findViewById(R.id.login);
  24. newuser = (Button)findViewById(R.id.register);
  25. uname = (EditText)findViewById(R.id.text_uname);
  26. pword = (EditText)findViewById(R.id.text_pword);
  27.  
  28. newuser.setOnClickListener(new View.OnClickListener() {
  29.  
  30. @Override
  31. public void onClick(View view) {
  32. // TODO Auto-generated method stub
  33. Intent myIntent = new Intent(view.getContext(), Register.class);
  34. startActivityForResult(myIntent, 0);
  35. finish();
  36. }
  37. });
  38.  
  39. login.setOnClickListener(new View.OnClickListener() {
  40.  
  41. @Override
  42. public void onClick(View view) {
  43. // TODO Auto-generated method stub
  44. if ( ( !uname.getText().toString().equals("")) && ( !pword.getText().toString().equals("")) )
  45. {
  46. Intent myIntent = new Intent(view.getContext(), Content.class);
  47. startActivityForResult(myIntent, 0);
  48. finish();
  49. }
  50. else if ( ( !uname.getText().toString().equals("")) )
  51. {
  52. Toast.makeText(getApplicationContext(),
  53. "Password field empty", Toast.LENGTH_SHORT).show();
  54. }
  55. else if ( ( !pword.getText().toString().equals("")) )
  56. {
  57. Toast.makeText(getApplicationContext(),
  58. "Email field empty", Toast.LENGTH_SHORT).show();
  59. }
  60. else
  61. {
  62. Toast.makeText(getApplicationContext(),
  63. "Email and Password field are empty", Toast.LENGTH_SHORT).show();
  64. }
  65.  
  66. }
  67. });
  68.  
  69. }
  70.  
  71. @Override
  72. public boolean onCreateOptionsMenu(Menu menu) {
  73. // Inflate the menu; this adds items to the action bar if it is present.
  74. getMenuInflater().inflate(R.menu.login, menu);
  75. return true;
  76. }
  77.  
  78. @Override
  79. public boolean onOptionsItemSelected(MenuItem item) {
  80. // Handle action bar item clicks here. The action bar will
  81. // automatically handle clicks on the Home/Up button, so long
  82. // as you specify a parent activity in AndroidManifest.xml.
  83. int id = item.getItemId();
  84. if (id == R.id.action_settings) {
  85. return true;
  86. }
  87. return super.onOptionsItemSelected(item);
  88. }
  89. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement