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

相关内容

热门资讯

透视游戏"xpoke... 透视游戏"xpoker辅助"详细辅助揭秘教程(原本是有挂)是一款可以让一直输的玩家,快速成为一个“必...
技术分享!we poker免费... 技术分享!we poker免费辅助器,hhpoker可以开挂吗,实用技巧(有挂教程);玩家必备必赢加...
透视玄学"德普之星辅... 透视玄学"德普之星辅助器怎么用"详细辅助软件教程(一直真的是有挂)这是由厦门游乐互动科技有限公司精心...
一起来探讨!竞技联盟透视,we... 一起来探讨!竞技联盟透视,wepoker如何设置透视,分享教程(有挂神器)是一款可以让一直输的玩家,...
透视好友房"wejo... 透视好友房"wejoker手机版透视脚本"详细辅助详细教程(果然存在有挂);建议优先通过wejoke...
推荐十款!哈糖大菠萝有没有挂,... 推荐十款!哈糖大菠萝有没有挂,wepoker免费透视脚本,透明挂教程(有挂技巧)是一款可以让一直输的...
透视脚本"pokem... 透视脚本"pokemmo手机版修改器"详细辅助曝光教程(最初真的有挂)准备好在pokemmo手机版修...
最新技巧!pokemmo手机版... 最新技巧!pokemmo手机版脚本免费,wepoker私人局辅助,细节方法(有挂透明);实战中需综合...
透视免费"aapok... 透视免费"aapoker脚本"详细辅助必赢方法(原来是真的有挂);玩家必备必赢加哟《13670430...
热门推荐!德州私人局脚本,we... 热门推荐!德州私人局脚本,wepoker透视挂底牌,解密教程(有挂神器);亲真的是有正版授权,小编(...