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 30th, 2011, 07:53 AM
Registered User
Points: 13, Level: 1
Points: 13, Level: 1 Points: 13, Level: 1 Points: 13, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2011
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Chapter 2 To Do List setOnKeyListener Problem

Hi,

I tried to execute the code mentioned in the book, but i keep getting the error

Multiple markers at this line
- The method setOnKeyListener(View.OnKeyListener) in the type View is not applicable for the arguments
(new DialogInterface.OnKeyListener(){})
- The type new DialogInterface.OnKeyListener(){} must implement the inherited abstract method
DialogInterface.OnKeyListener.onKey(DialogInterfac e, int, KeyEvent)



package com.androiddevelopment.todolist;

import java.util.ArrayList;

import android.app.Activity;
import android.content.DialogInterface.OnKeyListener;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.ListView;


public class ToDoListActivity extends Activity {
/** Called when the activity is first created. */
@Override
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);

// Bind the array adapter to the listview
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;
}
});
}

}
Reply With Quote
  #2 (permalink)  
Old November 1st, 2012, 07:35 AM
Registered User
Points: 3, Level: 1
Points: 3, Level: 1 Points: 3, Level: 1 Points: 3, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Unhappy me too

j'ai le même problème

the same problem for me!!!
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
To Do list chapter one WaJMHome BOOK: Professional Android 2 Application Development 8 November 14th, 2011 09:12 AM
Chapter 4 - To Do List solo BOOK: Professional Android 2 Application Development 1 June 15th, 2011 08:55 PM
Problem: Chapter 7 "Saving Your To-Do List" (Page 218) DrGaribaldi BOOK: Professional Android 2 Application Development 2 March 21st, 2011 01:53 AM
Chapter 6 To Do List EricTapia BOOK: Professional Android 2 Application Development 0 April 14th, 2010 01:40 AM
Chapter 19 Address List problem srgibson99 BOOK: Beginning VB.NET 2nd Edition/Beginning VB.NET 2003 1 June 15th, 2005 05:21 PM



All times are GMT -4. The time now is 05:48 AM.


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