app/src/main/java/com/example/steve/todoandroid/ToDoListActivity.java
//adds a new item to the listview
adds a new item to the listview
adds a new item to the listview
public void onAdd(View v)
    {
        EditText newTask = (EditText) findViewById(R.id.etxtListItem);
        String itemText = newTask.getText().toString();
        SimpleDateFormat df = new SimpleDateFormat("MM dd yyyy");
        String date = df.format(Calendar.getInstance().getTime());
        if (itemText.matches(""))
        {
            AlertDialog alertDialog = new AlertDialog.Builder(ToDoListActivity.this).create();
            alertDialog.setTitle("Alert");
            alertDialog.setMessage("List item cannot be blank");
            alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, "OK",
                    new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int which) {
                            dialog.dismiss();
                        }
                    });
            alertDialog.show();
        }
        else
        {
            toDoListAdapter.add(itemText);
            int curPos = toDoListAdapter.getPosition(itemText);
            toDoListAdapter.notifyDataSetChanged();
            newTask.setText("");
            toDoListDB.addListItem(curPos, itemText,PRIORITY_NORMAL,date,false);
            updateDBPositions();
        }
    }
public void onAdd ( View v ) { EditText newTask = ( EditText ) findViewById ( R . id . etxtListItem ) ; String itemText = newTask . getText ( ) . toString ( ) ; SimpleDateFormat df = new SimpleDateFormat ( "MM dd yyyy" ) ; String date = df . format ( Calendar . getInstance ( ) . getTime ( ) ) ; if ( itemText . matches ( "" ) ) { AlertDialog alertDialog = new AlertDialog . Builder ( ToDoListActivity . this ) . create ( ) ; alertDialog . setTitle ( "Alert" ) ; alertDialog . setMessage ( "List item cannot be blank" ) ; alertDialog . setButton ( AlertDialog . BUTTON_NEUTRAL , "OK" , new DialogInterface . OnClickListener ( ) { public void onClick ( DialogInterface dialog , int which ) { dialog . dismiss ( ) ; } } ) ; alertDialog . show ( ) ; } else { toDoListAdapter . add ( itemText ) ; int curPos = toDoListAdapter . getPosition ( itemText ) ; toDoListAdapter . notifyDataSetChanged ( ) ; newTask . setText ( "" ) ; toDoListDB . addListItem ( curPos , itemText , PRIORITY_NORMAL , date , false ) ; updateDBPositions ( ) ; } }
adds a new item to the listview
adds a new item to the listview
//Toast.makeText(ToDoListActivity.this,"cur time " + date,Toast.LENGTH_SHORT).show();