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 June 29th, 2010, 12:30 PM
Registered User
 
Join Date: Jun 2010
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Chapter 2 - Todo List error

I need some help. I'm a new android developer. I design websites but no C++ experience.

Anyway. I've followed the todo list instructions in chapter 2. But I keep getting an errod on the todolist.java file. I input the text as instructed:

public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

ListView myListView = (ListView)findViewById(R.id.myListView);
final EditText myEditText = (EditText)findViewById(R.id.myEditText);

final ArrayList<String> todoItems = new ArrayList<String>();
final ArrayAdapter<String> aa;
aa = new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1,
todoItems);
myListView.setAdapter(aa);

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){
todoItems.add(0, myEditText.getText().toString());
aa.notifyDataSetChanged();
myEditText.setText("");
return true;
} return false;
} });
}

Is anybody else having this issue?
 
Old July 15th, 2010, 07:17 PM
Registered User
 
Join Date: Jul 2010
Posts: 2
Thanks: 0
Thanked 2 Times in 1 Post
Default

@Jerrod1225: Most of the errors people are having with this app have to do with Key Listeners that are introduced in a later chapter. Page 38 explains why.

If you are having issues with this line
Code:
myEditText.setOnKeyListener(new OnKeyListener()
and you are using eclipse, put your mouse pointer over the term OnKeyListener.

When the tooltip pops up choose the "import onKeyListener (android.view.View)" class.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Chapter 7 ToDo List Code WDPetry BOOK: Professional Android 2 Application Development 3 February 28th, 2011 01:40 AM
Chapter 4 : Todo List Item, can't see text IAmCorbin BOOK: Professional Android 2 Application Development 1 June 29th, 2010 02:56 PM
ToDo List Problems - Chapter 4 wolverineik BOOK: Professional Android Application Development ISBN: 978-0-470-34471-2 0 February 28th, 2010 09:29 AM
Chapter 6 Todo List removeItem abowman BOOK: Professional Android Application Development ISBN: 978-0-470-34471-2 4 February 5th, 2010 11:18 AM
Chapter 4 Customising Your Todo List MMC2 BOOK: Professional Android Application Development ISBN: 978-0-470-34471-2 0 May 12th, 2009 08:34 AM





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