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;
}
});
}
}