on click listener application has stopped unexpectedly

by broomie » Mon, 30 Nov 2009 02:01:48 GMT

Sponsored Links

Android sdk 1.6 / eclipse

I am sure I have been a clot but just using teh android examples


I've checked again and again but cannot find the issue.

Error msg is "the application HelloDatePicker (process
helloDatePicker.localhost) has stopped unexpectedly" this happend when
I click on the "change teh date " button.

Here's my code..

package helloDatePicker.localhost;

import java.util.Calendar;

import android.app.Activity;
import android.app.DatePickerDialog;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.DatePicker;
import android.widget.TextView;

public class HelloDatePicker extends Activity {
/** Called when the activity is first created. */
// @Override
// public void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.main);

private TextView mDateDisplay;
private Button mPickDate;
private int mYear;
private int mMonth;
private int mDay;

static final int DATE_DIALOG_ID = 0;

protected void onCreate(Bundle savedInstanceState) {

// capture our View elements
mDateDisplay = (TextView) findViewById(R.id.dateDisplay);
mPickDate = (Button) findViewById(R.id.pickDate);

// add a click listener to the button
mPickDate.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {

// get the current date
final Calendar c = Calendar.getInstance();
mYear = c.get(Calendar.YEAR);
mMonth = c.get(Calendar.MONTH);
mDay = c.get(Calendar.DAY_OF_MONTH);

// display the current date
// updates the date we display in the TextView
private void updateDisplay() {
new StringBuilder()
// Month is 0 based so add 1
.append(mMonth + 1).append("-")
.append(mYear).append(" "));
// the callback received when the user "sets" the date in the dialog
private DatePickerDialog.OnDateSetListener mDateSetListener =
new DatePickerDialog.OnDateSetListener() {

public void onDateSet(DatePicker view, int year,
int monthOfYear, int dayOfMonth) {
mYear = year;
mMonth = monthOfYear;
mDay = dayOfMonth;


<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/

<TextView android:id="@+id/dateDisplay"

<Button android:id="@+id/pickDate"

on click listener application has stopped unexpectedly

by Lance Nanek » Mon, 30 Nov 2009 07:07:16 GMT

 hen you see the stopped unexpectedly message then you can check the
Logcat view in Eclipse or use the "adb logcat" command line tool from
the SDK to see the error. Although in this case it looks like you
didn't implement the onCreateDialog method. In order to use the
showDialog method you also need to implement onCreateDialog such that
it creates and returns the requested dialog. See step 4 in the URL you

On Nov 27, 11:26am, broomie <pabro...@googlemail.com> wrote:


Sponsored Links

on click listener application has stopped unexpectedly

by broomie » Mon, 07 Dec 2009 13:54:54 GMT


you were right I was a clot and mised out section 4!



On Nov 29, 11:06pm, Lance Nanek <lna...@gmail.com> wrote:


Other Threads

1. Android NDK - ObjC and code portability?

* Post moved from android-platform group *

First off let me give some background about myself and my inquiry: I
am an iPhone developer, and I am an Android developer. I have
embarked on a potentially interesting side project that others may
some use to. Just as a preamble, I am not looking to have any sort of
feedback on the benefits of Java versus Objective-C either
linguistically or efficiency etc. I am looking for viability of how
this can be accomplished.

In this project I have started, I have successfully compiled, tested,
and verified a variant of the Android NDK to build ObjC binaries for
the Android platform. After coercing the compiler to do my bidding
(along with hammering Xcode to recognize the new platform), my next
trick will be making a code compatible port of some of the base
frameworks from iPhone to the Android platform. I need suggestions on
the path of implementation for a few fundamentals...

Dynamic Libraries or Static?
Should my port build the framework libraries as dynamic and if so,
and where would they ideally be stored on the device?
If the frameworks should be static library inclusions into the built
applications, will this have a horrific adverse effect of the device
limitations per installed application size (my best guess is that it
will be an issue)?

Inherited UI or ported UI?
If I am successful in the port of Foundation, the next logical step
will be UIKit. I am a firm believer in consistency of the user
experience for operating systems, so a tie-in to the native UI would
be the best route in my opinion. This poses a quandary, how can a c/c
+/objc application bind into the Java based UI? Is there a lower
hook point for this? Can the JNI be bi-directional for connections to
UI elements?

The overall aim to this project is somewhat academic at the moment,
however for the concept of speed of porting applications to multiple
platforms this would definitely be quite attractive to developers
currently developing for iPhone and wanting to migrate to the android

I would love to hear any constructive ideas in regards to these

unsubscribe: android-porting+unsubscr...@googlegroups.com

2. Regarding SharedPreferences


Can you give me an example with the use of SharedPrefereneces which
store and retrieve the email and password by calling .net web service?


3. How to add buttons in StatusBar..

4. "You do not have permission to open this page"

5. How to store and retrieve email id and password using SharedPreferences?

6. Some application / market questions

7. InCallScreen activity failed to start when an MT call was received while BT headset is connected.