Hi,
I am new to android, after doing the notepad3 tutorial, I have one
applied it in one new project, I follow all the code and make my own
database and table. I try to put some data in the table. but in one
function called fillData(), I always have problems with
SimpleCursorAdapter. This is
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.notes_list);
mDbHelper = new News(this);
mDbHelper.open();
fillData();
registerForContextMenu(getListView());
}
private void fillData() {
mNotesCursor = mDbHelper.fetchAllNotes();
startManagingCursor(mNotesCursor);
String[] from = new String[]{News.TAB_adContent};
int[] to = new int[]{R.id.adsShow};
// Now create a simple cursor adapter and set it to display
SimpleCursorAdapter notes =
new SimpleCursorAdapter(this, R.layout.notes_row,
mNotesCursor, from, to);
setListAdapter(notes);
}
This is file note_list.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/
android"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ListView android:id="@android:id/android:list"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView android:id="@+id/android:empty"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/no_notes"/>
</LinearLayout>
This is file note_row.xml
<?xml version="1.0" encoding="utf-8"?>
<TextView android:id="@+id/adsShow" xmlns:android="http://
schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
why do I have InvocationTargetException once it run on
SimpleCursorAdapter notes =
new SimpleCursorAdapter(this, R.layout.notes_row,
mNotesCursor, from, to);
thanks
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en