how to open custom dialog box in a custom dialog box in android

Course Queries Syllabus Queries 3 years ago

3.85K 1 0 0 0

User submissions are the sole responsibility of contributors, with TuteeHUB disclaiming liability for accuracy, copyrights, or consequences of use; content is for informational purposes only and not professional advice.

Answers (1)

Post Answer
profilepic.png
manpreet Tuteehub forum best answer Best Answer 3 years ago


my app contains a custom dialog box on button click in which i have some check boxes on selecting one of this check box it show me another dialog box with 3 check boxes plz help me here is my code for opening first dialog box

ImageView img1 = (ImageView)findViewById(R.id.image_menu);
        img1.setOnClickListener(new OnClickListener() {

              @Override
              public void onClick(View arg0) {

                // custom dialog
                final Dialog dialog = new Dialog(MainActivity.this);
                dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
                dialog.setContentView(R.layout.menu);

                Button dialogButton = (Button) dialog.findViewById(R.id.btncross);
                // if button is clicked, close the custom dialog
                dialogButton.setOnClickListener(new OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        dialog.dismiss();
                    }
                });

                 dialog.show();
                 Spinner spin = (Spinner)dialog.findViewById(R.id.spinState);
                 ArrayAdapter<String> adapter_state = new ArrayAdapter<String>(MainActivity.this,  android.R.layout.simple_spinner_item, states);
                 adapter_state.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
                 spin.setAdapter(adapter_state);
                 spin.setSelection(pos);
                 spin.setOnItemSelectedListener(MainActivity.this);



                 Button btnShare = (Button)dialog.findViewById(R.id.btnShare);
                 btnShare.setOnClickListener(new OnClickListener() {

                    @Override
                    public void onClick(View arg0) {
                        // TODO Auto-generated method stub
                        Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND); 
                        sharingIntent.setType("text/plain"
0 views
0 shares

No matter what stage you're at in your education or career, TuteeHUB will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.

Similar Forum