我是android的新手。当我尝试获取联系人姓名时,它工作正常,但我只想获取数字,但我无法这样做。我的代码是:-
package com.example.sqllitecontactlist;
import android.app.Activity;
import android.database.Cursor;
import android.os.Bundle;
import android.provider.ContactsContract;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.SimpleCursorAdapter;
import android.widget.TextView;
import android.widget.AdapterView.OnItemClickListener;
public class PhoneBookActivity extends Activity {
//Android listview object
ListView listViewPhoneBook;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.phone_book);
//get the ListView Reference from xml file
listViewPhoneBook=(ListView)findViewById(R.id.listPhoneBook);
String[] arrayColumns = new String[]{ ContactsContract.CommonDataKinds.Phone.NUMBER};
// arrayViewID is the id of the view it will map to here textViewPhone only
int[] arrayViewID = new int[]{R.id.textViewNumber};
Cursor cursor = getContentResolver().query(ContactsContract.Contacts.CONTENT_URI, arrayColumns, null, null, null);
SimpleCursorAdapter adapter = new SimpleCursorAdapter(this, R.layout.each_contact, cursor, arrayColumns, arrayViewID);
listViewPhoneBook.setAdapter(adapter); }}
当我执行此操作时,它显示“java.lang.IllegalArgumentException:无效列 data1”。我用谷歌搜索了很多并应用了一些解决方案但失败了。请帮帮我