Code Package contacts. List;
Import Android. App. listactivity;
Import Android. database. cursor;
Import Android. provider. Contacts. People;
Import Android. OS. Bundle;
Import Android. widget. listadapter;
Import Android. widget. simplecursoradapter;
/**
*
* Data comes from a cursor.
*/
Public class contactslist extends listactivity {
@ Override
Protected void oncreate (bundle savedinstancestate ){
Super. oncreate (savedinstancestate );
// Get a cursor with all people
Cursor c = getcontentresolver (). Query (people. content_uri, null );
Startmanagingcursor (C );
Listadapter adapter = new simplecursoradapter (this,
// Use a template that displays a Text View
Android. R. layout. simple_list_item_1,
// Give the cursor to the list adatper
C,
// Map the name column in The People database...
New String [] {People. name },
// The "text1" view defined in the XML template
New int [] {Android. R. Id. text1 });
Setlistadapter (adapter );
}
}
Code <? XML version = "1.0" encoding = "UTF-8" ?>
< Manifest Xmlns: Android = "Http://schemas.android.com/apk/res/android"
Package = "Contacts. List"
Android: versioncode = "1"
Android: versionname = "1.0" >
< Uses-Permission Android: Name = "Android. Permission. read_contacts" />
< Application Android: icon = "@ Drawable/icon" Android: Label = "@ String/app_name" >
< Activity Android: Name = ". Contactslist"
Android: Label = "@ String/app_name" >
< Intent-Filter >
< Action Android: Name = "Android. Intent. Action. Main" />
< Category Android: Name = "Android. Intent. Category. sample_code" />
</ Intent-Filter >
</ Activity >
</Application>
</Manifest>
It was a simple thing, but it took me a lot of effort. It turned out to be a problem with the configuration file, and later it was a base class inheritance error. In any case, it was okay.