Guest User

Untitled

a guest
Dec 7th, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.73 KB | None | 0 0
  1. package com.basel.student_services;
  2.  
  3. public class LoginScreen extends AppCompatActivity {`
  4.  
  5. @Override
  6. protected void onCreate(Bundle savedInstanceState) {
  7. super.onCreate(savedInstanceState);
  8.  
  9. setContentView(R.layout.activity_login_screen);
  10.  
  11. Toolbar tb = (Toolbar)findViewById(R.id.login_tb);
  12. setSupportActionBar(tb);
  13.  
  14. }
  15.  
  16. public void login(View view) {
  17. EditText user = (EditText)findViewById(R.id.user);
  18. EditText pass = (EditText)findViewById(R.id.pass);
  19.  
  20. Intent myIntent = new Intent(this , Main.class);
  21. Bundle myBundle = new Bundle();
  22. myBundle.putString("txturs", user.getText().toString());
  23. myBundle.putString("txtpas", pass.getText().toString());
  24. myIntent.putExtras(myBundle);
  25. startActivity(myIntent);
  26.  
  27. }
  28. }
  29.  
  30. package com.basel.student_services;
  31.  
  32. public class Main extends AppCompatActivity {``
  33. Toolbar tb;
  34.  
  35. @Override
  36. protected void onCreate(Bundle savedInstanceState) {
  37. super.onCreate(savedInstanceState);
  38. setContentView(R.layout.activity_main);
  39.  
  40. Bundle bundleOfMain = getIntent().getExtras();
  41. String usr = bundleOfMain.getString("txturs");
  42. String pas = bundleOfMain.getString("txtpas");
  43.  
  44. TextView tv = (TextView)findViewById(R.id.textView2);
  45. tv.setText(usr +"n"+ pas);
  46.  
  47. tb = (Toolbar)findViewById(R.id.main_toolbar);
  48. setSupportActionBar(tb);
  49.  
  50. }
  51.  
  52. @Override
  53. public boolean onCreateOptionsMenu(Menu menu){
  54. MenuInflater m = getMenuInflater();
  55. m.inflate(R.menu.main_activity_menu, menu);
  56. return true;
  57. }
  58.  
  59.  
  60. @Override
  61. public boolean onOptionsItemSelected(MenuItem item ){
  62.  
  63. int id = item.getItemId();
  64. if (id == R.id.men1){
  65. Toast.makeText(this , "clicked 1" , Toast.LENGTH_LONG).show();
  66. }
  67.  
  68. return super.onOptionsItemSelected(item);
  69.  
  70. }
  71.  
  72. }
Add Comment
Please, Sign In to add comment