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: 无法设置文本”的问题。

相关内容

热门资讯

透视透视"wepok... 透视透视"wepoker脚本"详细辅助透明教程(购买模拟器技巧)1、点击下载安装,微扑克wpk插件透...
透视软件"hhpok... 透视软件"hhpoker德州透视挂"详细辅助可靠教程(轻量版透视系统方法)1、点击下载安装,微扑克w...
透视插件"哈糖大菠萝... 1、透视插件"哈糖大菠萝万能挂"详细辅助玩家教你(有辅助器攻略)(UU poker、哈糖大菠萝万能挂...
透视有挂"aapok... 透视有挂"aapoker发牌逻辑"详细辅助黑科技教程(有用辅助);《WPK辅助透视》‌:支持手机实时...
透视脚本"wepok... 透视脚本"wepoker游戏的安装教程"详细辅助实用技巧(作弊辅助技巧);建议优先通过wepoker...
透视私人局"wepo... 自定义wepoker透视脚本免费系统规律,只需要输入自己想要的开挂功能,一键便可以生成出微扑克专用辅...
透视肯定"we-po... 透视肯定"we-poker辅助"详细辅助2025教程(有辅助攻略);玩家必备必赢加哟《1367043...
透视好友"wepok... 透视好友"wepoker私人局透视插件"详细辅助AA德州教程(透视脚本免费下载pc软件);1.wep...
透视辅助"hhpok... 《透视辅助"hhpoker买挂"详细辅助2025新版(插件下载方法)》 hhpoker买挂软件透明挂...
透视神器"wepok... 透视神器"wepoker模拟器哪个"详细辅助2025新版总结(辅助器软件)是一款可以让一直输的玩家,...