Guest User

Untitled

a guest
Jul 21st, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.46 KB | None | 0 0
  1. package mah.mosa.skola;
  2.  
  3. import android.app.Activity;
  4. import android.content.Intent;
  5. import android.os.Bundle;
  6. import android.view.View;
  7. import android.view.View.OnClickListener;
  8. import android.widget.Button;
  9.  
  10. public class IndividiuellUppgiftActivity extends Activity implements
  11. OnClickListener {
  12. /** Called when the activity is first created. */
  13. @Override
  14. public void onCreate(Bundle savedInstanceState) {
  15. super.onCreate(savedInstanceState);
  16. setContentView(R.layout.main);
  17.  
  18. Button btn;
  19. Button btn2;
  20.  
  21. btn2 = (Button) findViewById(R.id.button2);
  22. btn = (Button) findViewById(R.id.button1);
  23.  
  24. btn.setOnClickListener(this);
  25. btn2.setOnClickListener(this);
  26. }
  27.  
  28. @Override
  29. public void onClick(View v) {
  30. Intent changeActivity;
  31. Intent changeActivity2;
  32. // v är vilken knapp som blivit nedtryckt
  33. if (v == btn) {
  34.  
  35. changeActivity = new Intent(IndividiuellUppgiftActivity.this,
  36. Search.class);
  37. // putExtra skickar med ett värde till nästa klass. Endast ena knappen skickar med ett extra värde.
  38. // Bundle extras = getIntent().getExtras(); <- Så hämtar man värdet.
  39. // if(extras != null){
  40. // setContentView(dinenalayout)
  41. // else { din andra layout
  42. //
  43. // bajs
  44.  
  45. changeActivity.putExtra("search", true);
  46. startActivity(changeActivity);
  47. }
  48. else if (v == btn2) {
  49. changeActivity = new Intent(IndividiuellUppgiftActivity.this,
  50. Search.class);
  51. startActivity(changeActivity);
  52. }
  53.  
  54. }
  55.  
  56. }
Add Comment
Please, Sign In to add comment