on click listener application has stopped unexpectedly

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


Sponsored Links
 olks

Android sdk 1.6 / eclipse

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

http://developer.android.com/guide/tutorials/views/hello-datepicker.html


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;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

// 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) {
showDialog(DATE_DIALOG_ID);
}
});

// 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
updateDisplay();
}
// updates the date we display in the TextView
private void updateDisplay() {
mDateDisplay.setText(
new StringBuilder()
// Month is 0 based so add 1
.append(mMonth + 1).append("-")
.append(mDay).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;
updateDisplay();
}
};
}


XML:

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

<TextView android:id="@+id/dateDisplay"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""/>

<Button android:id="@+id/pickDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content&quo



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

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


 ance

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


cheers


Paul

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

--



Other Threads

1. trouble installing ADT

I'm trying to install ADT to eclipse. but after add the address to the
update site and install, I get this error message:

An error occurred while collecting items to be installed
  No repository found containing: org.eclipse.ui.views.log/osgi.bundle/
1.0.0.v20080803-1700

Can someone tell a solution?

PS: I'm having a proxy set.

--~--~---------~--~----~------------~-------~--~----~

2. Recent Networking Article Posts...

Hi,

There is an interesting article here at tekwits. Thought you would be
beneficial if you read thisPublished on Networking (http://networking.tekwits.com)
Home > View / Post Articles

Esteem Rising
By tekwits_admin
Created 01/03/2009 - 08:33
Treasure is found in the diversity of people I meet personally and
professionally, my blog celebrates those gifts. It offers career
advice, delves into my thoughts and celebrates women's contributions
to society.

Source URL (retrieved on 01/03/2009 - 09:04): 
http://networking.tekwits.com/node/1320
Thanks,
Kevin

--~--~---------~--~----~------------~-------~--~----~

3. Androids music app

4. How to hook into the event for device rotation?

5. .apk file resource optimisation

6. I will help

7. MyLocationOverlay marker disappears