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. Heads Up: IME/IMF

Hi all,

If anyone is interested in the upcoming IME/IMF work being done in the
roadmap, you can now start looking at the code for it included in the
cupcake branch.  This is still far from finished, but is in good enough
shape to start using and writing IMEs against; though there will still be
some changes to the APIs, I don't expect any major ones at this point.

The start of some sample code for writing an IME is here:

http://android.git.kernel.org/?p=platform/development.git;a=tree;f=samples/SoftKeyboard;hb=cupcake

This is purely there as a sample, and not as a complete implementation of a
fully-featured soft keyboard.  There also should be much more documentation
showing up in the near future.

In builds being done in the cupcake branch, the sample soft keyboard should
be built for you and enabled.  This means that if you tap on an edit text in
the UI, and you don't have the hard keyboard available, you will get the
soft keyboard sample to enter text in to.

There are a few important things for app developers to know about
interacting well with the new input method system, which we will be talking
about more as the branch stabilizes and is ready for use as an SDK:

- There is a new android:inputType attribute and a setInputType() method on
TextView for controlling how your text should be managed.  These replace the
android:password, android:singleLine, android:numeric, android:phoneNumber,
android:inputMethod, android:capitalize, android:autotext, android:editable
attributes and let you specify additional details about your text.  People
developing against cupcake should use android:inputType in all new code.
The framework does interpret the old attributes into a new style input type,
but where you can it is good to update to android:inputType so you can
supply the additional information.

- There is a new "softInputMode" you can specify for a window, to control
whether the soft keyboard is displayed automatically when your window is
shown and whether your window is panned or resized when it is shown.  You
can specify this either with Window.setSoftInputMode(), in a custom Theme,
or with a new android:windowSoftInputMode attribute on an activity in its
manifest.  In general I think the system does a decent job of deciding what
to do with windows automatically, but there will certainly be cases where
you want to specify this yourself, especially to have the soft keyboard
displayed automatically.

- The way a user gets to a soft keyboard is by pressing on an editable text
view.  This means that applications must not implement their own behavior
for tapping on it.

- The new InputMethodManager class (which get be retrieved by
getSystemService()) provides programmatic control of the soft keyboard.

Have fun!

-- 
Dianne Hackborn
Android framework engineer
hack...@android.com

Note: please don't send private questions to me, as I don't have time to
provide private support.  All such questions should be posted on public
forums, where I and others can see and answer them.

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

2. Is it a bad idea to hardcode the memory card location ?

Thanks! that works.







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

3. HttpUrlConnection.disconnect doesn't work

4. problems with Gallery and gestures

5. Android Marketplace - No App Icon or Images?

6. Understanding animation repeat

7. Android Developer Console and the Market - Several Issues