Advertisement
Guest User

Untitled

a guest
Mar 9th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.92 KB | None | 0 0
  1. package net.susanu.laborator3;
  2.  
  3. import android.content.Intent;
  4. import android.os.Bundle;
  5. import android.support.v7.app.AppCompatActivity;
  6. import android.support.v7.widget.Toolbar;
  7. import android.view.View;
  8. import android.view.Menu;
  9. import android.view.MenuItem;
  10. import android.widget.EditText;
  11. import android.widget.Toast;
  12.  
  13. public class MainActivity extends AppCompatActivity {
  14. @Override
  15. protected void onCreate(Bundle savedInstanceState) {
  16. super.onCreate(savedInstanceState);
  17. setContentView(R.layout.activity_main);
  18. Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
  19. setSupportActionBar(toolbar);
  20. }
  21.  
  22. @Override
  23. public boolean onCreateOptionsMenu(Menu menu) {
  24. // Inflate the menu; this adds items to the action bar if it is present.
  25. getMenuInflater().inflate(R.menu.menu_main, menu);
  26. return true;
  27. }
  28.  
  29. @Override
  30. public boolean onOptionsItemSelected(MenuItem item) {
  31. // Handle action bar item clicks here. The action bar will
  32. // automatically handle clicks on the Home/Up button, so long
  33. // as you specify a parent activity in AndroidManifest.xml.
  34. int id = item.getItemId();
  35.  
  36. //noinspection SimplifiableIfStatement
  37. if (id == R.id.action_settings) {
  38. return true;
  39. }
  40.  
  41. return super.onOptionsItemSelected(item);
  42. }
  43.  
  44. public void login(View view){
  45. EditText username = (EditText)findViewById(R.id.username);
  46. EditText password = (EditText)findViewById(R.id.password);
  47.  
  48. if(username.getText().toString().equals("student") && password.getText().toString().equals("student")){
  49. Intent myIntent = new Intent(this, FindTheNumberActivity.class);
  50. startActivity(myIntent);
  51. }else {
  52. Toast.makeText(MainActivity.this, "Wrong username and password!", Toast.LENGTH_LONG).show();
  53. }
  54. }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement