class MainActivity : AppCompatActivity() { private val contactsList = ArrayList<String>() private lateinit var adapter: ArrayAdapter<String> override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) adapter = ArrayAdapter(this, android.R.layout.simple_list_item_1, contactsList) contactsView.adapter = adapter …… readContacts() } …… private fun readContacts() { // 查询联系人数据 contentResolver.query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null, null, null, null)?.apply { while (moveToNext()) { // 获取联系人姓名 val displayName = getString(getColumnIndex(ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME)) // 获取联系人手机号 val number = getString(getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER)) contactsList.add("$displayName $number") } adapter.notifyDataSetChanged() close() } } }