Advertisement
Guest User

Untitled

a guest
Aug 17th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.71 KB | None | 0 0
  1. package com.example.android.quizpsikologi;
  2.  
  3. import android.content.Intent;
  4. import android.support.v7.app.AppCompatActivity;
  5. import android.os.Bundle;
  6. import android.view.View;
  7. import android.widget.CheckBox;
  8. import android.widget.Button;
  9. import android.widget.CompoundButton;
  10. import android.widget.TextView;
  11. //import java.text.NumberFormat;
  12. //
  13. //import static android.R.attr.id;
  14. //import static android.R.attr.name;
  15.  
  16. public class MainActivity extends AppCompatActivity {
  17.  
  18. //private int answer = 0;
  19. private CheckBox agreementcheckbox;
  20. private Button buttonnext1;
  21. private int haschecked = 0;
  22. private TextView testuji;
  23.  
  24. @Override
  25. protected void onCreate(Bundle savedInstanceState)
  26. {
  27. super.onCreate(savedInstanceState);
  28. setContentView(R.layout.activity_main);
  29. agreementcheckbox = (CheckBox) findViewById(R.id.agreement);
  30. buttonnext1 = (Button) findViewById(R.id.next1);
  31. testuji = (TextView) findViewById(R.id.test);
  32. }
  33.  
  34. public void enable (View view)
  35. {
  36. if (agreementcheckbox.isChecked())
  37. {
  38. haschecked = 1;
  39. }
  40. else
  41. {
  42. haschecked = 0;
  43. }
  44. testuji.setText("" + haschecked);
  45.  
  46. condition(haschecked);
  47. }
  48.  
  49. public void condition (int number)
  50. {
  51. if (number >=1 )
  52. {
  53. buttonnext1.setEnabled(true);
  54. activity_main2(); // pindah ke Activity baru
  55. }
  56. else
  57. {
  58. buttonnext1.setEnabled(false);
  59. }
  60. }
  61.  
  62. private void activity_main2 ()
  63. {
  64. testuji.setText("Masih Bisa");
  65. Intent activity_main2_Page = new Intent (this, Main2Activity.class);
  66. startActivity(activity_main2_Page);
  67. }
  68.  
  69.  
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement