This is my MainActivity. I getting an involving a list adapter I believe. I'm just confused on how I go about to fix the specific problem I am currently facing.
public class MainActivity extends ListActivity {
private Todo todo;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//Creating todo object
todo = new Todo(this);
//Set the list adapter to get list from Todo
//I believe this is one fo the places that is causing the error
setListAdapter(new ListAdd(this, todo.getTodo()));
}
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
//TODO item that was clicked
TodoInfo todoInfo = (TodoInfo)getListAdapter().getItem(position);
//Delete todo object from the database
todo.deleteTodo(todoInfo.getId());
//Set the list adapter and get Todos list from todo
setListAdapter(new ListAdd(this, todo.getTodo()));
//Display a message
Toast.makeText(getApplicationContext(), "Deleted the item!", Toast.LENGTH_SHORT).show();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
Intent intent = new Intent(this, Todo.class);
startActivity(intent);
this.finish();
todo.close();
return super.onOptionsItemSelected(item);
}
}
This is my xml file for my MainActivity. I'm using a List View.
<ListView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:paddingTop="40dp">
<TextView
android:id="@+id/todoText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Text Goes Here"/>
</ListView>
I Just really want to know exactly what I'm doing wrong and how can I fix it for what I am trying to do. Any help will be greatly appreciated.