I'm trying just to get a simple ListView to update when clicking an add button on my UI and taking the edittext and putting in the listview. Can someone look at this and tell me what I'm doing wrong. I've searched here and the developer site and can't figure it out. Thanks
import java.util.ArrayList;
import android.app.Activity;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnKeyListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ListView;
public class TaskTracker extends Activity {
private Button addButton;
int count = 0;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
addButton=(Button)findViewById(R.id.button1);
ListView myListView= (ListView)findViewById(R.id.myListView);
final EditText myEditText= (EditText)findViewById(R.id.editText1) ;
final ArrayList<String> taskitems = new ArrayList<String>();
final ArrayAdapter<String> aa;
aa = new ArrayAdapter<String>(this, 0);
myListView.setAdapter(aa);
addButton.setOnClickListener(new OnClickListener(){
public void onClick(View v){
taskitems.add(count, myEditText.getText().toString());
aa.notifyDataSetChanged();
myEditText.setText("");
count++;
finish();
}
});
}
}