Have you stepped through the code to ensure that every line is getting
executed as expected and checked the variables list to make sure all
the expected values are set?

The one thing I am curious about is these lines:
           todoItems.add(0, myEditText.getText().toString());
            myEditText.setText("");

I haven't used in Java in a good 2 years, so I could be forgetting the
specifics, but since Java handles everything as pointers behind the
scenes, when you call setText(""), the pointer that you is created by
todoItems.add() may also be getting set to "" and therefore comes out
blank.  Try commenting out the setText(""); and see if that does
anything.



On Dec 10, 7:07 am, Mat <mtarb...@bi-software.com> wrote:
> I have the same issue as you. I am stuck on this application as it
> appears the OnKeyListener does not work for some reason. I tried to
> set the text also, but it never gets executed. I also ran the sample
> application with the same result.
>
> I am a little miffed to say the least that the applications provided
> in a relatively new book do not work. If anyone has experience with
> this could they help?
>
> Thanks
>
> Mat
>
> On Dec 8, 3:18 pm, pnball2k <fred.winog...@gmail.com> 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(new OnKeyListener() {
> >          public boolean onKey(View v, int keyCode, KeyEvent event) {
> >            if (event.getAction() == KeyEvent.ACTION_DOWN)
> >           if (keyCode == KeyEvent.KEYCODE_DPAD_CENTER)
> >              {
> >             // Add a new todo 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 android-beginners@googlegroups.com
To unsubscribe from this group, send email to
android-beginners-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to