MyBlogShare

Proses Registrasi di Main Activity

Jul 7th, 2021
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.87 KB | None | 0 0
  1. package com.example.lenovo.myapplication;
  2.  
  3. import android.app.AlertDialog;
  4. import android.content.DialogInterface;
  5. import android.content.Intent;
  6. import android.support.v7.app.AppCompatActivity;
  7. import android.os.Bundle;
  8. import android.view.View;
  9. import android.widget.Button;
  10. import android.widget.EditText;
  11. import android.widget.TextView;
  12.  
  13. import com.example.lenovo.myapplication.proses.proses_crud;
  14.  
  15. public class MainActivity extends AppCompatActivity {
  16.  
  17.     EditText username, password, ulangpass;
  18.     Button btn_daftar;
  19.     TextView login;
  20.     AlertDialog.Builder builder;
  21.  
  22.     @Override
  23.     protected void onCreate(Bundle savedInstanceState) {
  24.         super.onCreate(savedInstanceState);
  25.         setContentView(R.layout.activity_main);
  26.  
  27.         username = (EditText) findViewById(R.id.username);
  28.         password = (EditText) findViewById(R.id.password);
  29.         ulangpass = (EditText) findViewById(R.id.password_konf);
  30.         btn_daftar = (Button) findViewById(R.id.button);
  31.        
  32.         btn_daftar.setOnClickListener(new View.OnClickListener() {
  33.             @Override
  34.             public void onClick(View v) {
  35.                 if (username.getText().toString().equals("")||password.getText().toString().equals("")){
  36.                     builder = new AlertDialog.Builder(FormRegister.this);
  37.                     builder.setTitle("Informasi");
  38.                     builder.setMessage("Your fill not input..!!");
  39.                     builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
  40.                         @Override
  41.                         public void onClick(DialogInterface dialogInterface, int i) {
  42.                             dialogInterface.dismiss();
  43.                         }
  44.                     });
  45.                     AlertDialog alertDialog = builder.create();
  46.                     alertDialog.show();
  47.                 }else if (!password.getText().toString().equals(ulangpass.getText().toString())){
  48.                     builder = new AlertDialog.Builder(FormRegister.this);
  49.                     builder.setTitle("Informsi");
  50.                     builder.setMessage("Maaf password dan ulangi password tidak sama...!");
  51.                     builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
  52.                         @Override
  53.                         public void onClick(DialogInterface dialogInterface, int i) {
  54.                             dialogInterface.dismiss();
  55.                         }
  56.                     });
  57.                     AlertDialog alertDialog = builder.create();
  58.                     alertDialog.show();
  59.                 }
  60.                 else {
  61.                     proses_crud backgroundTask = new proses_crud(FormRegister.this);
  62.                      backgroundTask.execute("Daftar", username.getText().toString(),password.getText().toString());
  63.                 }
  64.             }
  65.         });
  66.     }
  67.  
  68.  
  69. }
Advertisement
Add Comment
Please, Sign In to add comment