Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ssl/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用Delphi FMX通讯簿组件获取手机号码_Delphi_Firemonkey - Fatal编程技术网

如何使用Delphi FMX通讯簿组件获取手机号码

如何使用Delphi FMX通讯簿组件获取手机号码,delphi,firemonkey,Delphi,Firemonkey,德尔菲法10.3。 跨平台应用。 安卓和IOS。 我正在使用TAddressbook组件和以下从Delphi代码示例改编的代码。 我能够获得姓名和照片,但无法计算电话号码的语法。 代码用firstname/nam姓氏和image填充列表视图,但Contact.Phones似乎是一个数组 我在文档中找到了这个 Phones.AddPhone(TContactPhone.TLabelKind.Mobile, '+33-6-46-51-3531'); So I need somthing like t

德尔菲法10.3。 跨平台应用。 安卓和IOS。 我正在使用TAddressbook组件和以下从Delphi代码示例改编的代码。 我能够获得姓名和照片,但无法计算电话号码的语法。 代码用firstname/nam姓氏和image填充列表视图,但Contact.Phones似乎是一个数组

我在文档中找到了这个

Phones.AddPhone(TContactPhone.TLabelKind.Mobile, '+33-6-46-51-3531');
So I need somthing like this
Phones.Extract(TContactPhone.TLabelKind.Mobile); // Does not work.

procedure TformMain.FillContactList(Source: TAddressBookSource);
var
  I: Integer;
  Contacts: TAddressBookContacts;
begin
  Contacts := TAddressBookContacts.Create;
  try
    AddressBook1.AllContacts(Source, Contacts);
    ListViewContacts.BeginUpdate;
    try
      ListViewContacts.Items.Clear;
      for I := 0 to Contacts.Count - 1 do
        AddListViewItem(Contacts.Items[I]);
        //AddListViewItem(Contacts.Items[I].Phones[0].Number)
    finally
      ListViewContacts.EndUpdate;
    end;
  finally
    Contacts.Free;
  end;
end;
procedure TformMain.AddListViewItem(Contact: TAddressBookContact);
var

  ListViewItem: TListViewItem;
  eMails: TContactEmails;
  phones: TContactPhones;
  c : TAddressBookContact;

begin


      phones := Contact.Phones;
      if Contact.DisplayName.Length > 0 then
  begin
  ListViewItem := ListViewContacts.Items.Add;
  try

     // ListViewItem.Data['Text2'] :=  Contact.Phones.Extract(TContactPhone.SupportedLabelKinds('Mobile'));
     // ListViewItem.Data['Text2'] :=  Phones.ExtractItem.LabelText. (TContactPhone.TLabelKind.Mobile, '+33-6-46-51-3531');
      //ListViewItem.Data['Text2'] :=  Phones.ex ExtractItem AddPhone(TContactPhone.TLabelKind.Mobile, '+33-6-46-51-3531');
      ListViewItem.Data['Text1'] := Contact.DisplayName;
      ListViewItem.Data['Text2'] := '07446944654';  // from sample eMails.AddEmail(TContactEmail.TLabelKind.Work, edtWorkMail.Text);
//    TLabelKind = (Custom, Home, Mobile, Work, iPhone, FaxWork, FaxHome, FaxOther, Pager, Other, Callback, Car, CompanyMain,ISDN, Main, Radio, Telex, TTYTDD, WorkMobile, WorkPager, Assistant);
//    ListViewItem.Data['Text2']  := c.Phones.First.LabelKind.Mobile.t;// Phones.IndexOf('Mobile');
//    ListViewItem.Data['Text2'] := Contact.Phones.ExtractItem('Mobile');
//    ListViewItem.Data['Text2'] := Contact.Phones.Extract.LabelKind('Mobile');
//    ListViewItem.Data['Text2'] := Contact.Phones.ExtractAt.LabelKind.Mobile;//('Mobile');
//    phones := Contact.Phones.ExtractItem.LabelKind.Mobile; //.TLabelKind.Mobile;// .Phones.Extract(Mobile);
//    ListViewItem.Data['Text2'] := phones.ExtractAt.LabelKind.Mobile;// Extract.LabelKind.Mobile;// ExtractItem.LabelKind.Mobile;//  Contact.Phones.Extract('Mobile').ToString;// Phones.Extract.TLabelKind.;
//    ListViewItem.Data['Text2'] := phones.Extract.LabelKind.Mobile;//  Contact.Phones Items[0].TLabelKind. .Number;// .Items[0];
      ListViewItem.Data['Image3'] := Contact.PhotoThumbnail;

    ListViewItem.Tag := Contact.ID;
  finally
    ListViewItem.Free;
  end;

  end;

end;

我无法在原始帖子中添加我的代码,因为它说“看起来像垃圾邮件”。代码是1750个字符,所以不能放在这里。如何将代码添加到此对话中?是的,我已经阅读了文档。我之所以想展示我的代码,是为了让你知道我不是在不请自来。该行可以正常工作ListViewItem.Data['Text1']:=Contact.DisplayName;ListViewItem.Data['Text2']:=Contact.Phones.Extract(TContactPhone.SupportedLabelKinds('Mobile');ListViewItem.Data['Text2']:=Phones.ExtractItem.LabelText。(t contactphone.TLabelKind.Mobile,“+33-6-46-51-3531”);ListViewItem.Data['Text2']:=Phones.ex ExtractItem AddPhone(TContactPhone.TLabelKind.Mobile,“+33-6-46-51-3531”);ListViewItem.Data['Text2']:=c.Phones.First.LabelKind.Mobile.t;//电话。IndexOf(“手机”);ListViewItem.Data['Text2']:=Contact.Phones.ExtractItem('Mobile');ListViewItem.Data['Text2']:=Contact.Phones.Extract.LabelKind('Mobile');ListViewItem.Data['Text2']:=Contact.Phones.ExtractAt.LabelKind.Mobile//(‘移动’);电话:=Contact.phones.ExtractItem.LabelKind.Mobile;//。TLabelKind.Mobile;//。电话。摘录(手机);ListViewItem.Data['Text2']:=phones.ExtractAt.LabelKind.Mobile;//Extract.LabelKind.Mobile;//ExtractItem.LabelKind.Mobile;//Contact.Phones.Extract('Mobile').ToString;//电话。摘录。特拉贝尔金。;您希望在q中包含代码是完全正确的。使用“复制/粘贴”将其添加到q中,然后选择它并按Ctrl-K以正确布局。我无法在原始帖子中添加我的代码,因为它声明“看起来像垃圾邮件”。代码是1750个字符,所以不能放在这里。如何将代码添加到此对话中?是的,我已经阅读了文档。我之所以想展示我的代码,是为了让你知道我不是在不请自来。该行可以正常工作ListViewItem.Data['Text1']:=Contact.DisplayName;ListViewItem.Data['Text2']:=Contact.Phones.Extract(TContactPhone.SupportedLabelKinds('Mobile');ListViewItem.Data['Text2']:=Phones.ExtractItem.LabelText。(t contactphone.TLabelKind.Mobile,“+33-6-46-51-3531”);ListViewItem.Data['Text2']:=Phones.ex ExtractItem AddPhone(TContactPhone.TLabelKind.Mobile,“+33-6-46-51-3531”);ListViewItem.Data['Text2']:=c.Phones.First.LabelKind.Mobile.t;//电话。IndexOf(“手机”);ListViewItem.Data['Text2']:=Contact.Phones.ExtractItem('Mobile');ListViewItem.Data['Text2']:=Contact.Phones.Extract.LabelKind('Mobile');ListViewItem.Data['Text2']:=Contact.Phones.ExtractAt.LabelKind.Mobile//(‘移动’);电话:=Contact.phones.ExtractItem.LabelKind.Mobile;//。TLabelKind.Mobile;//。电话。摘录(手机);ListViewItem.Data['Text2']:=phones.ExtractAt.LabelKind.Mobile;//Extract.LabelKind.Mobile;//ExtractItem.LabelKind.Mobile;//Contact.Phones.Extract('Mobile').ToString;//电话。摘录。特拉贝尔金。;您希望在q中包含代码是完全正确的。使用“复制/粘贴”将其添加到q中,然后选择它并按Ctrl-K以正确布局。