Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Android
Search Coderanch
Advance search
Google search
Register / Login
Win a copy of
Java Persistence with Spring Data and Hibernate
this week in the
Spring
forum!
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Ron McLeod
Tim Cooke
Paul Clapham
Liutauras Vilda
Sheriffs:
Junilu Lacar
Rob Spoor
Jeanne Boyarsky
Saloon Keepers:
Stephan van Hulst
Carey Brown
Tim Holloway
Piet Souris
Bartenders:
Forum:
Android
Loader class instaed of startManagingCursor
Kasun Wixkramanayake
Ranch Hand
Posts: 74
posted 9 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
import android.os.Bundle; import android.provider.ContactsContract.CommonDataKinds.Phone; import android.app.Activity; import android.app.ListActivity; import android.database.Cursor; import android.view.Menu; import android.widget.ListAdapter; public class CustomBaseAdapterActivity extends ListActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.list); String[] projections = new String[] { Phone._ID, Phone.DISPLAY_NAME, Phone.NUMBER, Phone.TYPE }; Cursor c = getContentResolver().query(Phone.CONTENT_URI, projections, null, null, null); startManagingCursor(c); List<ContactEntry> contacts = new ArrayList<ContactEntry>(); while (c.moveToNext()) { int nameCol = c.getColumnIndex(Phone.DISPLAY_NAME); int numCol = c.getColumnIndex(Phone.NUMBER); int typeCol = c.getColumnIndex(Phone.TYPE); String name = c.getString(nameCol); String number = c.getString(numCol); int type = c.getInt(typeCol); contacts.add(new ContactEntry(name, number, type)); } // CREATE ADAPTER USING LIST OF CONTACT OBJECTS ContactBaseAdapter cAdapter = new ContactBaseAdapter(this, this.setAdapter } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.custom_base_adapter, menu); return true; } }
i use above code to display contact numbers on the screen. how i use
Loader class
class instead of
startManagingCursor(c);
snakes are really good at eating slugs. And you wouldn't think it, but so are tiny ads:
The Low Tech Laboratory Movie Kickstarter is LIVE NOW!
https://www.kickstarter.com/projects/paulwheaton/low-tech
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Pop up window over android native incoming call screen like true caller android app
problems with row position in Cursor Listview Adapter
Reading a .xlsx excel file using XSSF
android web service returned HTTP request failed, HTTP status: 500
Can't read the image from the database after insertion.
More...