Advertisement
Guest User

Android BaseAdapter Test Code

a guest
Aug 9th, 2016
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.45 KB | None | 0 0
  1. package com.example.testingapp;
  2.  
  3. import android.database.Cursor;
  4. import android.provider.ContactsContract;
  5. import android.view.View;
  6. import android.view.ViewGroup;
  7. import android.widget.BaseAdapter;
  8.  
  9. import java.util.ArrayList;
  10.  
  11. /**
  12.  * Created by omarq on 09-Aug-16.
  13.  */
  14.  
  15. class contactsRow {
  16.  
  17.     String image;
  18.     String name;
  19.     String number;
  20.  
  21. }
  22.  
  23. class ContactsAdapter extends BaseAdapter {
  24.  
  25.     ArrayList<contactsRow> contactsArray;
  26.  
  27.     ContactsAdapter() {
  28.         contactsArray = new ArrayList<contactsRow>();
  29.  
  30.         Cursor phones = getContentResolver().query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null, null, null, null);
  31.         while (phones.moveToNext()) {
  32.             String name = phones.getString(phones.getColumnIndex(ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME));
  33.             String phoneNumber = phones.getString(phones.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER));
  34.             //Toast.makeText(getActivity().getApplicationContext(),name, Toast.LENGTH_LONG).show();
  35.  
  36.             String full = name + " " + phoneNumber;
  37.  
  38.  
  39.         }
  40.  
  41.     }
  42.  
  43.     @Override
  44.     public int getCount() {
  45.         return 0;
  46.     }
  47.  
  48.     @Override
  49.     public Object getItem(int i) {
  50.         return null;
  51.     }
  52.  
  53.     @Override
  54.     public long getItemId(int i) {
  55.         return 0;
  56.     }
  57.  
  58.     @Override
  59.     public View getView(int i, View view, ViewGroup viewGroup) {
  60.         return null;
  61.     }
  62.  
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement