1

How to create alert dialogs with or without xml as per image below ? sample code will help.

  1. Seekbar is disabled when checkbox is checked.

alertDialog with checkbox and seekbar

For this dialog, I was able to create some short of dialog but, I am not sure how to place check box and its logic if checkbox is checked/uncheckd, seekbar needs to disabled/enabled.

public void ShowDialog()
{
    final AlertDialog.Builder popDialog = new AlertDialog.Builder(this);
    popDialog.setPositiveButton("OK",
    new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
        }
    });
    popDialog.setNegativeButton("Cancel",
    new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
        }
    });

    final SeekBar seek = new SeekBar(this);
    seek.setMax( ... );
    seek.setProgress(...);
    final AlertDialog handle = popDialog.create();

    handle.setIcon(android.R.drawable.ic_menu_preferences);     
    handle.setTitle("Brighness"); 
    handle.setView(seek);

    seek.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser){
            //Log.d(TAG, "Value of : " + value);
        }

        public void onStartTrackingTouch(SeekBar arg0) {
            //Log.d(TAG, "onStartTrackingTouch");
        }

        public void onStopTrackingTouch(SeekBar seekBar) {
            //Log.d(TAG, "onStopTrackingTouch");
        }
    });
    handle.show();      
}
  1. Auto line is dimmed when seekbar is highlighted.

Auto dimmed, seekbar highlighted

  1. seekbar is dimmed when Auto line is highlighted.

Auto highlighted, seekbar dimmed

I have checked other questions, those are more about custom dialogs : How to create a Custom Dialog box in android? But, None of these are giving me clear idea so, I am asking this specific question.

Community
  • 1
  • 1
apache
  • 133
  • 1
  • 2
  • 9
  • Possible duplicate of [How to create a Custom Dialog box in android?](http://stackoverflow.com/questions/13341560/how-to-create-a-custom-dialog-box-in-android) – AL. Jun 26 '16 at 23:21
  • @intj - it is in direction of custom dialog but those answers are more generic for custom dialog. I have updated the description. – apache Jun 26 '16 at 23:39
  • Okay.. I'm pretty sure with that post you can come up with a custom alertdialog yourself. But have you seen the mentioned docs in this [post](http://stackoverflow.com/q/2795300/4625829)? – AL. Jun 26 '16 at 23:41
  • 1
    @inij - sorry for my limited know-how in android. I have tried various sample code but, didn't succeeded on this. I have updated my code with question. – apache Jun 27 '16 at 00:03
  • No worries. Are you having any error with your code? Posting a screenshot with what you're getting would also be helpful. :) – AL. Jun 27 '16 at 02:23

0 Answers0