Android - Populate listview using SimpleCursorAdapter (about to loose the will to live, lol)?

The error you are getting is most likely because you're trying to embed a TextView into a ListView.

The error you are getting is most likely because you're trying to embed a TextView into a ListView... Remove the TextView from the ListView and then try the following... String from = new String {"answer"}; int to = new int {android.R.id. Text1}; SimpleCursorAdapter cursorAdapter = new SimpleCursorAdapter(context, android.R.layout. Simple_list_item_1, answers, from, to); This uses the pre-defined Android android.R.layout.

Simple_list_item_1 and android.R.id. Text1.

Thank you both for answering me so quickly after posting, I really appreciate it. I now have the following code, and I am still getting a force close: ListView answerList=(ListView)findViewById(R.id. AnswerList); String from = new String {"answer"}; int to = new int {android.

R.id. Text1}; SimpleCursorAdapter cursorAdapter = new SimpleCursorAdapter(context, android.R.layout. Simple_list_item_1, answers, from, to); answerList.

SetAdapter(cursorAdapter); My err msg: Your content must have a ListView whose id attribute is 'android. R.id. List' – javaMonkey Jun 14 at 20:04 @javaMonkey: Did you change Activity to ListActivity?

If so, you've just slightly complicated things. – MisterSquonk Jun 14 at 20:22 Weird, now I am trying and getting this error: 06-14 21:23:17.852: ERROR/AndroidRuntime(19652): java.lang. RuntimeException: Unable to start activity ComponentInfo{com.example.

Magic8/com.example. Magic8. AnswerList}: java.lang.

NullPointerException. I have looked into what this means, but I can't see anything causing it. – javaMonkey Jun 14 at 20:24 @MisterSquonk No, I didn't change it to ListActivity.

– javaMonkey Jun 14 at 20:27 @javaMonkey: Try changing the 'id' for your ListView in the xml file to android:id="@android:id/list" - you'll also have to change it for findViewById(android. R.id. List) – MisterSquonk Jun 14 at 20:41.

Your to and from need to be the same length. You don't need to include _id in the 'from' array. Note that you still need to have _id in your cursor.

Just like to thank you to for helping me, I really appreciate it! – javaMonkey Jun 14 at 20:11.

The error you are getting is most likely because you're trying to embed a TextView into a ListView...

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions