title: How to make Custom button work in custom alert Dialog Box using android
body: <pre><code>public class MainActivity extends AppCompatActivity
  {
      private TextView regis;
      public Button bt_ok;
      @Override
      protected void onCreate(Bundle savedInstanceState)
      {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
          bt_ok=findViewById(R.id.bt_ok);
          getSupportActionBar().hide();
          SharedPreferences prefs = getSharedPreferences(&quot;prefs&quot;, MODE_PRIVATE);
          boolean firstStart = prefs.getBoolean(&quot;firstStart&quot;, true);
          if (firstStart)
          {
              showStartDialog();
          }
      }
      public void showStartDialog()
      {
          LayoutInflater inflater = LayoutInflater.from(this);
          View view =inflater.inflate(R.layout.activity_dialog,null);
          final AlertDialog.Builder dialog= new AlertDialog.Builder(MainActivity.this,R.style.DialogCustomTheme);
          final View customLayout = getLayoutInflater().inflate(R.layout.activity_dialog,null);
          dialog.setView(customLayout).create();
          dialog.setCancelable(false);
          dialog.show();
          SharedPreferences prefs = getSharedPreferences(&quot;prefs&quot;, MODE_PRIVATE);
          SharedPreferences.Editor editor = prefs.edit();
          editor.apply();
          }
  }
  </code></pre>
  <p>I am unable to make the custom button work , my requirement is simple when my custom dialog box is opened i have to dismiss it by simply clicking on button i dont want to use in-built alert dialog box buttons.Please help me thankyou in advance.</p>