java - setListAdapter() not working -
import android.app.activity; import android.os.bundle; import android.app.listactivity; import android.database.cursor; import android.net.uri; import android.provider.contactscontract; import android.widget.simplecursoradapter; public class mainactivity extends activity { @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); uri allcontacts = uri.parse("content://contacts/people"); cursor c = managedquery(allcontacts, null, null, null, null); string[] columns = new string[] { contactscontract.contacts.display_name, contactscontract.contacts._id}; int[] views = new int[] {r.id.contactname, r.id.contactid}; simplecursoradapter adapter = new simplecursoradapter(this, r.layout.activity_main, c, columns,views); this.setlistadapter(adapter); } }
it shows error :the method setlistadapter(simplecursoradapter) undefined type mainactivity
in order use setlistadapter
class has extends listactivity
not activity
. change
public class mainactivity extends activity
with
public class mainactivity extends listactivity
Comments
Post a Comment