Android Place Autocomplete Fragment: 无法设置文本
创始人
2024-08-15 00:30:14
0

要解决“Android Place Autocomplete Fragment: 无法设置文本”问题,可以尝试以下解决方法:

  1. 在使用Place Autocomplete Fragment之前,确保你已经在build.gradle文件中正确导入了Google Places API库:
implementation 'com.google.android.gms:play-services-places:17.0.0'
  1. 在布局文件中,确保Place Autocomplete Fragment的容器使用的是com.google.android.gms.location.places.ui.PlaceAutocompleteFragment类:

  1. 在代码中,使用PlaceAutocompleteFragment类的实例来设置文本,而不是PlaceAutocompleteFragment类的实例。确保你导入了正确的类:
import com.google.android.gms.location.places.ui.PlaceAutocompleteFragment;
  1. 使用以下代码在你的Activity或Fragment中设置文本:
PlaceAutocompleteFragment autocompleteFragment = (PlaceAutocompleteFragment)
    getFragmentManager().findFragmentById(R.id.place_autocomplete_fragment);

autocompleteFragment.setOnPlaceSelectedListener(new PlaceSelectionListener() {
    @Override
    public void onPlaceSelected(Place place) {
        // 在这里设置文本
        EditText et = (EditText) autocompleteFragment.getView().findViewById(R.id.place_autocomplete_search_input);
        et.setText(place.getName().toString());
    }

    @Override
    public void onError(Status status) {
        // 处理错误
    }
});

在上述代码中,我们在onPlaceSelected()方法中获取到了PlaceAutocompleteFragment的EditText,并设置了文本。

这些解决方法应该能够帮助你解决“Android Place Autocomplete Fragment: 无法设置文本”的问题。

相关内容

热门资讯

透视ai"wejok... 这是一款非常优秀的wejoker手机版透视脚本 ia辅助检测软件,能够让你了解到wejoker手机版...
透视好友"hhpok... 透视好友"hhpoker免费辅助器"详细辅助第三方教程(正确养号方法技巧);致您一封信;亲爱hhpo...
透视科技"德州真人透... 《透视科技"德州真人透视脚本"详细辅助技巧教程(钻石可以看底牌透视)》 德州真人透视脚本软件透明挂更...
透视安卓版"we p... 透视安卓版"we poker辅助器v3.3"详细辅助可靠教程(辅助软件透明)1、不需要AI权限,帮助...
透视工具"wepok... 《透视工具"wepoker辅助是真的假的"详细辅助第三方教程(有透视底牌攻略)》 wepoker辅助...
透视游戏"德普之星透... 透视游戏"德普之星透视辅助软件下载"详细辅助科技教程(辅助器可以弄神器);玩家必备必赢加哟《1367...
透视规律"hhpok... 透视规律"hhpoker外挂靠谱吗"详细辅助攻略方法(手机版透视脚本软件)是一款可以让一直输的玩家,...
透视黑科技"wepo... 透视黑科技"wepoker买脚本靠谱吗"详细辅助存在挂教程(免费透视脚本软件);致您一封信;亲爱we...
透视智能ai"wep... 透视智能ai"wepoker安装教程"详细辅助AA德州教程(有挂软件);科技安装教程;1367043...
透视肯定"hhpok... 1、透视肯定"hhpoker有辅助吗"详细辅助实用技巧(俱乐部辅助技巧)。2、hhpoker有辅助吗...