OK, after some trial and error I found that the following code worked
fine:
myEditText.setOnKeyListener(new OnKeyListener() {
public boolean onKey(View v, int keyCode, KeyEvent event) {
if (event.getAction() == KeyEvent.ACTION_DOWN)
if (keyCode == KeyEvent.KEYCODE_ENTER) {
todoItems.add(0, myEditText.getText().toString());
myEditText.setText("");
aa.notifyDataSetChanged();
return true;
}
return false;
}
});
all I did was replace the KeyEvent.KEYCODE_DPAD_CENTER with
KeyEvent.KEYCODE_ENTER
Hope this helps.
Mat
On Dec 8, 3:18 pm, pnball2k <[EMAIL PROTECTED]> wrote:
> I'm working on some sample programs in the Professional Android
> Applications book and was trying to run the debugger in Eclipse. When
> I do, I do not see the results of a line the should change the text in
> the emulator. I put a line in the code "myEditText.setText("Testing
> 123");" and expect to see that value when I execute that line in the
> code. I do not have any errors ort messages in Eclipse.
>
> I do know the line is functioal because "Testing 123" is set in a
> ListView later in the code. Look for the comment "HERE IS THE LINE I
> ADDED"
>
> The code is:
>
> myEditText.setOnKeyListener(newOnKeyListener() {
> public boolean onKey(View v, int keyCode, KeyEvent event) {
> if (event.getAction() == KeyEvent.ACTION_DOWN)
> if (keyCode == KeyEvent.KEYCODE_DPAD_CENTER)
> {
> // Add anewtodo item and clear the input box.
> // HERE IS THE LINE I ADDED
> myEditText.setText("Testing 123");
> todoItems.add(0, myEditText.getText().toString());
> myEditText.setText("");
> aa.notifyDataSetChanged();
> return true;
> }
> return false;
> }
> });
>
> What am I doing incorrectly?
>
> Thanks
> Fred
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---