So ive just begun to start on my android development learning journey
and got this book Profession Android Application Development, but I
cant get this certain sample code to run and im so new to the sdk I
cant spot the problem. Well obviously eclipse tells me why it wont
compile ive gotten it down from a host of errors just importing
thhings into the document but one red line is still under new
OnKeyListener. Any suggestions appreciated I feel i have too many
imports as well so let me know just started learning hate when these
book examples dont work.

package com.paad.todolist;

import android.app.Activity;
import android.os.Bundle;
import android.view.*;
import android.widget.*;
import android.util.*;
import java.util.*;



public class ToDoList extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle icicle) {

        setContentView(R.layout.main);

        //get references to ui widgets
        ListView myListView = (ListView)findViewById(R.id.myListView);
        final EditText myEditText = (EditText)findViewById
(R.id.myEditText);

        //Create Array List of Todo Items
        final ArrayList<String> todoItems = new ArrayList<String>();
        //Create array adapter to bind arraylist to list items
        final ArrayAdapter<String> aa;
        aa = new ArrayAdapter<String>(this,
                        android.R.layout.simple_list_item_1,
                        todoItems);
        //bind to list view
        myListView.setAdapter(aa);

        //Setup next user next entry
        myEditText.setOnKeyListener(new OnKeyListener(){
                public boolean onKey(View v, int keyCode, keyEvent event){
                        if (event.getAction()== keyEvent.ACTION_DOWN)
                                if (keyCode == keyCode.KEYCODE_DPAD_CENTER)
                                {
                                        todoItems.add(0, 
myEditText.getText().toString());
                                        aa.notifyDataSetChanged();
                                        myEditText.setText("");
                                        return true;
                                }
                        return false;
             }
                });
        }

}

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to