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> > > 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