Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
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;
}
});

}

}
Reply With Quote
  #2 (permalink)  
Old January 4th, 2010, 04:27 PM
Registered User
 
Join Date: Jan 2010
Location: Texas
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.
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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 05: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 09:14 PM
Chapter2 netblue BOOK: Professional XNA Game Programming: For Xbox 360 and Windows ISBN: 978-0-470-12677-6 2 June 5th, 2007 02: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 11:23 AM



All times are GMT -4. The time now is 06:25 AM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.