Displaying Contact Number and Contact Name in a custom list view

Since op asked for the solution using custom adapter i have posted the below.(from the comments) Display.java public class Display extends Activity implements OnItemClickListener{ List<String> name1 = new ArrayList<String>(); List<String> phno1 = new ArrayList<String>(); MyAdapter ma ; Button select; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.display); getAllContacts(this.getContentResolver()); ListView lv= (ListView) findViewById(R.id.lv); ma = new … Read more

Android: Using SimpleCursorAdapter to get Data from Database to ListView

Using the database format in the tutorial that you linked to, every row has an _id, isbn, title, and publisher. Now let’s assume that you want to display every title in a ListView: db = new DBAdapter(this); SimpleCursorAdapter adapter = new SimpleCursorAdapter(this, android.R.layout.simple_list_item_1, db.getAllTitles(), new String[] { “title” }, new int[] { android.R.id.text1 }); ListView … Read more

AlphabetIndexer with Custom Adapter managed by LoaderManager

So I finally got this to work. Here’s how i did it: I added: ListView lv = getListView(); lv.setFastScrollEnabled(true); lv.setScrollingCacheEnabled(true); to the onLoadFinished() method after the new cursor was swapped in like so public void onLoadFinished(Loader<Cursor> loader, Cursor data) { // Swap the new cursor in. (The framework will take care of closing the // … Read more

SimpleCursorTreeAdapter and CursorLoader for ExpandableListView

So i figured out that I needed to map loaderids to groupPositions and this solved my issue: Here is my Fragment class which implements the CursorLoader public class GroupsListFragment extends ExpandableListFragment implements LoaderManager.LoaderCallbacks<Cursor> { private final String DEBUG_TAG = getClass().getSimpleName().toString(); private static final String[] CONTACTS_PROJECTION = new String[] { ContactsContract.Contacts._ID, ContactsContract.Contacts.DISPLAY_NAME }; private static final … Read more