Wrox Programmer Forums
|
BOOK: Professional Android Application Development ISBN: 978-0-470-34471-2
This is the forum to discuss the Wrox book Professional Android Application Development by Reto Meier; ISBN: 9780470344712
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional Android Application Development ISBN: 978-0-470-34471-2 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 21st, 2009, 11:50 AM
Registered User
 
Join Date: Dec 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Chapter2 error

Evironment
JDK : 1.6
Eclipse : 3.5
SDK : 2.0.1
I got error message.
(The application To Do List (process com.jeon.todolist)has stopped
unexpectedly. please try again.

What is problem?

Thanks,
Sam

Example Code.

package com.jeon.todolist;

import java.util.ArrayList;
import android.app.Activity;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnKeyListener;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.ListView;

public class ToDoList extends Activity {

@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);

// Inflate your view
setContentView(R.layout.main);

// Get references to UI widgets
ListView myListView = (ListView)findViewById(R.id.myListView);
final EditText myEditText = (EditText)findViewById(R.id.myEditText);

// Create the ArrayList and the ArrayAdapter
final ArrayList<String> todoItems = new ArrayList<String>();
final ArrayAdapter<String> aa = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1,todoItems);

// Bind the listview to the array adapter
myListView.setAdapter(aa);

// Add key listener to add the new todo item
// when the middle D-pad button is pressed.
myEditText.setOnKeyListener(new OnKeyListener() {
public boolean onKey(View v, int keyCode, KeyEvent event) {
if (event.getAction() == KeyEvent.ACTION_DOWN)
if (keyCode == KeyEvent.KEYCODE_DPAD_CENTER) {
// Add the new todo item, and clear the input text box
todoItems.add(0, myEditText.getText().toString());
myEditText.setText("");
aa.notifyDataSetChanged();
return true;
}
return false;
}
});

}

}
 
Old January 4th, 2010, 04:27 PM
Registered User
 
Join Date: Jan 2010
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Re: Chapter2 Error

I got the same error when I neglected to call super.onCreate(icicle).

That invocation does not appear in my text.

When I put it in, things worked.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Chapter2: IENTBaseEntity Implementation Haegendoorn BOOK: ASP.NET 3.5 Enterprise Application Development with Visual Studio 2008: Problem Design Solutio 5 September 24th, 2009 04:50 AM
Chapter2: Compilation Error. krytonx85 BOOK: ASP.NET 3.5 Enterprise Application Development with Visual Studio 2008: Problem Design Solutio 2 June 18th, 2009 08:14 PM
Chapter2 netblue BOOK: Professional XNA Game Programming: For Xbox 360 and Windows ISBN: 978-0-470-12677-6 2 June 5th, 2007 01:19 AM
Chapter2:problem in rendering weather table samouille666 JSP Basics 0 January 17th, 2007 10:50 AM
Compiled error of executing chapter2 source code williamlin BOOK Beginning Linux Programming, 3rd Edition 10 August 25th, 2006 10:23 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.