1

i've look on google and on the stack overflow and have not been able to find an answer that wants to work. I'm following a tutorial from the book "Professional android 4 application development" that creates a To do list. the only error in my code is what eclipse is giving me as an error message in my code, once i can fix this i believe it should run fine but i have been staring at it for an hour now and the frustration has got to me i can't understand what is wrong with the code and why i'm getting the error message in my code.

it only underlines the one word add which i have presented in the code below with three * on each side of the word any help would be greatly appreciated, thanks

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // Inflate the view to the main screen
    setContentView(R.layout.activity_to_do_list);

    // Get the references to the UI widgets
    ListView myListView = (ListView) findViewById(R.id.myListView);
    final EditText myEditText = (EditText) findViewById(R.id.myEditText);

    // create the array list of to do items
    final ArrayList<string> todoItems = new ArrayList<string>();

    // Create the array list of to do items
    final ArrayAdapter<string> aa;

    // Create the Array Adapter to bind the array to the list view
    aa = new ArrayAdapter<string>(this,
            android.R.layout.simple_list_item_1, todoItems);

    // Bind the array adapter to the List View
    myListView.setAdapter(aa);

    myEditText.setOnKeyListener(new View.OnKeyListener() {
        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;
        }
    });

}

}

2
  • Looking at the structure, it seems if you remove the "0" argument in the add function, it should work... Commented Sep 26, 2012 at 12:45
  • Thanks for the input but unfortunately it did not work :( Commented Sep 26, 2012 at 12:51

1 Answer 1

7

Replace

ArrayList<string>

by

ArrayList<String>
Sign up to request clarification or add additional context in comments.

2 Comments

Dystroy thankyou aha, such a silly mistake by me (Note to self check spelling next time)
Jesus why don't they come with a better editor to point this out ... i'm missing visual studio :(

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.