Advertisement
yayachadazt

android validasi

Sep 15th, 2014
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.28 KB | None | 0 0
  1. public void onClick(View view) {
  2. // TODO Auto-generated method stub
  3. try {
  4. Double hrg = Double.parseDouble(hargabaru.getText().toString());
  5. Double dp=Double.parseDouble(uangmuka.getText().toString());
  6. Double bnga=Double.parseDouble(text1.getText().toString());
  7. Double bln=Double.parseDouble(bulan1.getText().toString());
  8. Double asuransi=Double.parseDouble(asuransi1.getText().toString());
  9. if(hargabaru.getText().equals("")){
  10. AlertDialog.Builder alertDialog = new AlertDialog.Builder(adira.this);
  11.  
  12. // Setting Judul Dialog
  13. alertDialog.setTitle("Warning");
  14.  
  15. // Setting Pesan Dialog
  16. alertDialog.setMessage("DP Belum Di Isi");
  17.  
  18. // Setting icon untuk Dialog
  19.  
  20.  
  21. // Setting tombol OK
  22. alertDialog.setNeutralButton("OK", new DialogInterface.OnClickListener() {
  23.  
  24. public void onClick(DialogInterface dialog, int which) {
  25. // Menulis code dibawah ini akan di eksekusi setelah Dialog keluar
  26.  
  27. }
  28. });
  29.  
  30. alertDialog.show();
  31.  
  32. }else if (uangmuka.getText().equals("")) {
  33.  
  34. AlertDialog.Builder alertDialog = new AlertDialog.Builder(adira.this);
  35.  
  36. // Setting Judul Dialog
  37. alertDialog.setTitle("Warning");
  38.  
  39. // Setting Pesan Dialog
  40. alertDialog.setMessage("Harga Belum Di Isi");
  41.  
  42. // Setting icon untuk Dialog
  43.  
  44.  
  45. // Setting tombol OK
  46. alertDialog.setNeutralButton("OK", new DialogInterface.OnClickListener() {
  47.  
  48. public void onClick(DialogInterface dialog, int which) {
  49. // Menulis code dibawah ini akan di eksekusi setelah Dialog keluar
  50.  
  51. }
  52. });
  53.  
  54. alertDialog.show();
  55.  
  56.  
  57. }else if(hrg<dp){
  58. AlertDialog.Builder alertDialog = new AlertDialog.Builder(adira.this);
  59.  
  60. // Setting Judul Dialog
  61. alertDialog.setTitle("Warning");
  62.  
  63. // Setting Pesan Dialog
  64. alertDialog.setMessage("Uang Muka Lebih Besar Dari Harga");
  65.  
  66. // Setting icon untuk Dialog
  67.  
  68.  
  69. // Setting tombol OK
  70. alertDialog.setNeutralButton("OK", new DialogInterface.OnClickListener() {
  71.  
  72. public void onClick(DialogInterface dialog, int which) {
  73. // Menulis code dibawah ini akan di eksekusi setelah Dialog keluar
  74. uangmuka.setText("");
  75. hargabaru.setText("");}
  76. });
  77.  
  78. alertDialog.show();
  79.  
  80. }else{
  81.  
  82. Double dpnet=dp-200000-(asuransi*hrg);
  83. Double pokok_hutang=hrg-dpnet;
  84. Double bunga_angsuran=pokok_hutang*bnga;
  85. Double angsuran=(pokok_hutang+bunga_angsuran)/bln;
  86. DecimalFormat df = new DecimalFormat("@@##");
  87. hasil2.setText("Rp." + df.format(angsuran) + ",00");
  88. }
  89.  
  90. } catch (Exception e) {
  91. AlertDialog.Builder alertDialog = new AlertDialog.Builder(adira.this);
  92.  
  93. // Setting Judul Dialog
  94. alertDialog.setTitle("Warning");
  95.  
  96. // Setting Pesan Dialog
  97. alertDialog.setMessage("Data Belum Lengkap");
  98.  
  99. // Setting icon untuk Dialog
  100.  
  101.  
  102. // Setting tombol OK
  103. alertDialog.setNeutralButton("OK", new DialogInterface.OnClickListener() {
  104.  
  105. public void onClick(DialogInterface dialog, int which) {
  106. // Menulis code dibawah ini akan di eksekusi setelah Dialog keluar
  107.  
  108. }
  109. });
  110.  
  111. alertDialog.show();
  112. }
  113. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement