可以在AndroidX.Fragment.App.Fragment内部使用Android Places SDK中的AutocompleteSupportFragment吗?

问题描述

我有一个继承自Android.Support.V4.App.Fragment的片段,在这个片段中,我从Android Places SDK中添加一个AutocompleteSupportFragment 。要初始化自动完成片段,请执行以下代码

public class PlacesFragment : Android.Support.V4.App.Fragment,Google.Places.IPlaceSelectionListener
{
    ...

    public override void OnViewCreated(View view,Bundle savedInstanceState)
    {
        base.OnViewCreated(view,savedInstanceState);

        var autocompleteFragment = (AutocompleteSupportFragment)ChildFragmentManager.FindFragmentById(Resource.Id.autocompleteFragment);

        var fields = new List<Google.Places.Place.Field>
        {
            Google.Places.Place.Field.Id,Google.Places.Place.Field.Name,};

        autocompleteFragment.SetPlaceFields(fields);
        autocompleteFragment.SetonPlaceSelectedListener(this);
    }
    
    ...
}

这可以按预期工作,并且没有任何问题。

现在,由于将不再维护Android支持库(如docs所述),我想将PlacesFragment迁移到最新的AndroidX库。问题是,如果我将PlacesFragment更改为从AndroidX.Fragment.App.Fragment继承,则错误 CS0030无法将类型'AndroidX.Fragment.App.Fragment'转换为'Google.Places.AutocompleteSupportFragment'语句var autocompleteFragment = (AutocompleteSupportFragment)ChildFragmentManager.FindFragmentById(Resource.Id.autocompleteFragment);,这很有意义,因为AutocompleteSupportFragment仍然继承自Android.Support.V4.App.Fragment

我错过了什么吗?是否可以在AndroidX片段中使用来自Android Places SDK的AutocompleteSupportFragment?

我正在使用Xamarin.Google.Android.Places nuget package的1.1.0.2版本,据我所知,这是最新的可用版本。

预先感谢

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)