Hello,

I tried to have a toast as well but it didn't seem to work. The button
where I had toast was buttoncalender1.

package com.varun.HelloListView;

import java.util.Calendar;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.DatePickerDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Toast;


public class screen3 extends Activity implements OnClickListener{
        private int mYear;
        private int mMonth;
        private int mDay;

        private final int DATE_DIALOG_ID = 0;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.form_screen_3);
        Button button = (Button) findViewById(R.id.Buttonsubmit);
        button.setOnClickListener(this);
    }
    public void onClick(View view) {
         /** check whether the yesno button has been clicked */
        if (view == findViewById(R.id.Buttonsubmit)) {
            // Create the dialog box
            AlertDialog.Builder alertbox = new
AlertDialog.Builder(this);
            // Set the message to display
            alertbox.setMessage("This is a dialog box with two
buttons");
             // Set a positive/yes button and create a listener
            alertbox.setPositiveButton("Yes", new
DialogInterface.OnClickListener() {
                // Click listener
                public void onClick(DialogInterface arg0, int arg1) {
                    Toast.makeText(getApplicationContext(), "'Yes'
button clicked", Toast.LENGTH_SHORT).show();
                }
            });
            // Set a negative/no button and create a listener
            alertbox.setNegativeButton("No", new
DialogInterface.OnClickListener() {
                // Click listener
                public void onClick(DialogInterface arg0, int arg1) {

                    Toast.makeText(getApplicationContext(), "'No'
button clicked", Toast.LENGTH_SHORT).show();
                }
            });
            // display box
            alertbox.show();
                /*...@override
           public void onClick(View v) {
            Toast.makeText(screen3.this, "The report #1234 has been
submitted to Mr XYZ", Toast.LENGTH_SHORT).show();
           }
         }); */
        /** check whether the selectlist button has been clicked */
        if (view == findViewById(R.id.btnCalendar1)) {
                //List items
                final CharSequence[] items = {"Milk", "Butter", "Cheese"};
                //Prepare the list dialog box
                AlertDialog.Builder builder = new AlertDialog.Builder(this);
                //Set its title
                builder.setTitle("Pick an item");
                //Set the list items and assign with the click listener
                builder.setItems(items, new DialogInterface.OnClickListener()
{
                        // Click listener
                        public void onClick(DialogInterface dialog, int item) {
                        Toast.makeText(getApplicationContext(), items[item],
Toast.LENGTH_SHORT).show();
                    }
                });
                AlertDialog alert = builder.create();
                //display dialog box
                alert.show();
        }
        }
        Button btnCalendar = (Button) findViewById(R.id.btnCalendar);
                btnCalendar.setOnClickListener(new OnClickListener() {
                        @Override
                        public void onClick(View v) {
                                showDialog(DATE_DIALOG_ID);
                        }
                });
                final Calendar c = Calendar.getInstance();
                mYear = c.get(Calendar.YEAR);
                mMonth = c.get(Calendar.MONTH);
                mDay = c.get(Calendar.DAY_OF_MONTH);
    }
        @Override
        protected Dialog onCreateDialog(int id) {
                switch (id) {
                case DATE_DIALOG_ID:
                        return new DatePickerDialog(this, null, mYear, mMonth, 
mDay);
                }
                return null;

    }

}



On Oct 15, 12:17 pm, Varun Khanduja <varunkhand...@gmail.com> wrote:
> Log cat is not showing any errors as such. Isn't
> showDialog(DATE_DIALOG_ID); the show call to the dialog?
>
> On Oct 15, 11:54 am, Kumar Bibek <coomar....@gmail.com> wrote:
>
>
>
> > Any errors in the logcat? Try showing a toast in the event. I  think you are
> > missing a show call to the dialog
>
> > On Sat, Oct 16, 2010 at 12:21 AM, Varun Khanduja 
> > <varunkhand...@gmail.com>wrote:
>
> > > Sorry about that. R.id.btnCalendar is not working. Thanks
>
> > > On Oct 15, 11:44 am, Kumar Bibek <coomar....@gmail.com> wrote:
> > > > Which button click is not working? You have to be more specific in
> > > > describing your problem.
>
> > > > On Sat, Oct 16, 2010 at 12:11 AM, Varun Khanduja <
> > > varunkhand...@gmail.com>wrote:
>
> > > > > Hi,
>
> > > > > I am not sure why my on button click is not working for the calender
> > > > > icon I have, does any one knows what I may be doing wrong?
>
> > > > > Here is my java code, thanks in advance.
>
> > > > > package com.varun.HelloListView;
>
> > > > > import java.util.Calendar;
>
> > > > > import android.app.Activity;
> > > > > import android.app.AlertDialog;
> > > > > import android.app.DatePickerDialog;
> > > > > import android.app.Dialog;
> > > > > import android.content.DialogInterface;
> > > > > import android.os.Bundle;
> > > > > import android.view.View;
> > > > > import android.view.View.OnClickListener;
> > > > > import android.widget.Button;
> > > > > import android.widget.Toast;
>
> > > > > public class screen3 extends Activity implements OnClickListener{
> > > > >        private int mYear;
> > > > >        private int mMonth;
> > > > >        private int mDay;
>
> > > > >        private final int DATE_DIALOG_ID = 0;
> > > > >   �...@override
> > > > >    public void onCreate(Bundle savedInstanceState) {
> > > > >        super.onCreate(savedInstanceState);
> > > > >        setContentView(R.layout.form_screen_3);
> > > > >        Button button = (Button) findViewById(R.id.Buttonsubmit);
> > > > >        button.setOnClickListener(this);
>
> > > > >    }
> > > > >    public void onClick(View view) {
>
> > > > >         /** check whether the yesno button has been clicked */
> > > > >        if (view == findViewById(R.id.Buttonsubmit)) {
> > > > >            // Create the dialog box
> > > > >            AlertDialog.Builder alertbox = new
> > > > > AlertDialog.Builder(this);
> > > > >            // Set the message to display
> > > > >            alertbox.setMessage("This is a dialog box with two
> > > > > buttons");
> > > > >             // Set a positive/yes button and create a listener
> > > > >            alertbox.setPositiveButton("Yes", new
> > > > > DialogInterface.OnClickListener() {
> > > > >                // Click listener
> > > > >                public void onClick(DialogInterface arg0, int arg1) {
> > > > >                    Toast.makeText(getApplicationContext(), "'Yes'
> > > > > button clicked", Toast.LENGTH_SHORT).show();
> > > > >                }
> > > > >            });
> > > > >            // Set a negative/no button and create a listener
> > > > >            alertbox.setNegativeButton("No", new
> > > > > DialogInterface.OnClickListener() {
> > > > >                // Click listener
> > > > >                public void onClick(DialogInterface arg0, int arg1) {
>
> > > > >                    Toast.makeText(getApplicationContext(), "'No'
> > > > > button clicked", Toast.LENGTH_SHORT).show();
>
> > > > >                }
>
> > > > >            });
>
> > > > >            // display box
>
> > > > >            alertbox.show();
>
> > > > >        }
>
> > > > >                /*...@override
> > > > >           public void onClick(View v) {
> > > > >            Toast.makeText(screen3.this, "The report #1234 has been
> > > > > submitted to Mr XYZ", Toast.LENGTH_SHORT).show();
> > > > >           }
> > > > >         }); */
>
> > > > >        Button btnCalendar = (Button) findViewById(R.id.btnCalendar);
> > > > >                btnCalendar.setOnClickListener(new OnClickListener() {
> > > > >                       �...@override
> > > > >                        public void onClick(View v) {
> > > > >                                showDialog(DATE_DIALOG_ID);
> > > > >                        }
> > > > >                });
> > > > >                final Calendar c = Calendar.getInstance();
> > > > >                mYear = c.get(Calendar.YEAR);
> > > > >                mMonth = c.get(Calendar.MONTH);
> > > > >                mDay = c.get(Calendar.DAY_OF_MONTH);
> > > > >    }
>
> > > > >       �...@override
> > > > >        protected Dialog onCreateDialog(int id) {
> > > > >                switch (id) {
> > > > >                case DATE_DIALOG_ID:
> > > > >                        return new DatePickerDialog(this, null, mYear,
> > > > > mMonth, mDay);
> > > > >                }
> > > > >                return null;
> > > > >    }
> > > > > }
>
> > > > > --
> > > > > You received this message because you are subscribed to the Google
> > > > > Groups "Android Developers" group.
> > > > > To post to this group, send email to
> > > android-developers@googlegroups.com
> > > > > To unsubscribe from this group, send email to
> > > > > android-developers+unsubscr...@googlegroups.com<android-developers%2Bunsubs
> > > > >  cr...@googlegroups.com><android-developers%2Bunsubs
> > > cr...@googlegroups.com>
> > > > > For more options, visit this group at
> > > > >http://groups.google.com/group/android-developers?hl=en
>
> > > > --
> > > > Kumar Bibekhttp://techdroid.kbeanie.comhttp://www.kbeanie.com
>
> > > --
> > > You received this message because you are subscribed to the Google
> > > Groups "Android Developers" group.
> > > To post to this group, send email to android-developers@googlegroups.com
> > > To unsubscribe from this group, send email to
> > > android-developers+unsubscr...@googlegroups.com<android-developers%2Bunsubs
> > >  cr...@googlegroups.com>
> > > For more options, visit this group at
> > >http://groups.google.com/group/android-developers?hl=en
>
> > --
> > Kumar Bibekhttp://techdroid.kbeanie.comhttp://www.kbeanie.com

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to