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 4 Application Development
This is the forum to discuss the Wrox book Professional Android 4 Application Development Reto Meier; ISBN: 978-1-1181-0227-5
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional Android 4 Application Development 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 January 11th, 2014, 10:21 PM
Registered User
Points: 5, Level: 1
Points: 5, Level: 1 Points: 5, Level: 1 Points: 5, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2014
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Chapter 4 ToDoList Part 1

Hi guys, I've been following step by step the code to the first example of the ToDoList App but, even though it compiles perfectly and run on my device, it seems that the keypress event is never reached.

This is the code:

myEditText.setOnKeyListener(new View.OnKeyListener() {
@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
if (event.getAction() == KeyEvent.ACTION_DOWN)
{
if ((keyCode == KeyEvent.KEYCODE_DPAD_CENTER)||
(keyCode == KeyEvent.KEYCODE_ENTER)){
todoItems.add(0, myEditText.getText().toString());
aa.notifyDataSetChanged();
myEditText.setText("");
return true;
}
}
return false;
}
});

I'm using Android Studio instead of Eclipse, maybe it has something to do with this error, or maybe the code in the example is too old and some parts are deprecated already...

Thanks in advance...
Reply With Quote
  #2 (permalink)  
Old January 19th, 2014, 06:01 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: Jan 2014
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

can u upload the full code?
Reply With Quote
  #3 (permalink)  
Old March 7th, 2014, 05:07 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: Mar 2014
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

There is a solution mentioned in this post by NeedAName:


1. I needed to make the EditText accept single line input only. I did this in the <EditText> node (I also set the button to "Done"):
android:singLine="true"
android:imeOptions="actionDone"

2. Next, in the onCreate() I added the following after the "myListView.setAdapter(aa);" line:

// Catch the "done" button on softkeyboard
myEditText.setOnEditorActionListener(new EditText.OnEditorActionListener(){
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if (actionId == EditorInfo.IME_ACTION_DONE){
//done Clicked
addTextToListView(myEditText, todoItems, aa);
return true;
}
return false;
}
});

Try it.

Cheers MF
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
Chapter 8 ToDoList Database michael_mctear BOOK: Professional Android 4 Application Development 11 December 18th, 2013 08:34 AM
Chapter 4 ToDoList Problem cythe BOOK: Professional Android Application Development ISBN: 978-0-470-34471-2 6 June 15th, 2011 10:53 PM
ToDoList Chapter 5 Line painting rich833 BOOK: Professional Android 2 Application Development 0 April 27th, 2011 10:28 AM
Chapter 2 - ToDoList Example srkrkalyan BOOK: Professional Android Application Development ISBN: 978-0-470-34471-2 3 January 22nd, 2011 01:09 PM
chapter 2 todolist kdpohl1 BOOK: Professional Android Application Development ISBN: 978-0-470-34471-2 5 July 16th, 2010 04:59 AM



All times are GMT -4. The time now is 10:20 PM.


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