Wrox Programmer Forums
| 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 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
  #1 (permalink)  
Old December 30th, 2011, 08: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;
}
});
}

}
  #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!!!


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 10: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





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