首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >android -添加按钮到自动完成搜索框

问android -添加按钮到自动完成搜索框
EN

Stack Overflow用户
提问于 2016-12-26 22:04:26
回答 1查看 2.3K关注 0票数 0

我已经在我的安卓应用程序中实现了谷歌的PlaceAutocompleteFragment,如下所示。

​

但我想在最后添加一个按钮--谷歌地图是如何配备麦克风的。

​

​

下面是到目前为止我的代码:

代码语言:javascript
复制
<android.support.v7.widget.CardView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_margin="8dp"
    >
    <fragment
        android:id="@+id/place_autocomplete_fragment"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:name="com.google.android.gms.location.places.ui.PlaceAutocompleteFragment"
        />
</android.support.v7.widget.CardView>

地点选择代码:

代码语言:javascript
复制
autocompleteFragment.setOnPlaceSelectedListener(new PlaceSelectionListener() {
        @Override
        public void onPlaceSelected(Place place) {
            String placeName = place.getName().toString();
            LatLng latLng = place.getLatLng();
            mMap.addMarker(new MarkerOptions().position(latLng).title(placeName));
            mMap.animateCamera(CameraUpdateFactory.newLatLng(latLng));

        }
        @Override
        public void onError(Status status) {
            // TODO: Handle the error.
            Log.i(TAG, "An error occurred: " + status);
        }
    });

一个示例代码就好了。(非常感谢:)

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-12-29 15:56:48

很抱歉这么晚才回复,但是由于一些错误,我已经重新安装并下载了整个Android和SDK

以下是我对你的建议:-

  1. 使用第三个库FloatingSearchView
  2. 要自定义您自己,这将分别花一些时间到第三个库,下面是一些帮助您自定义Google Place自动完成Android和如何自定义PlaceAutocomplete小部件对话框设计以列出位置问题的简单教程
  3. 是尝试在Google代码中更深入地进行自定义,知道这将通过扩展Google类和复制Google代码的全部代码来实现,然后编辑它是一个再生类 另外,最后一步,我已经深入到它,代码是知道这个方法是创建谷歌搜索的方法。 私有zzzG() { int var1 = -1;尝试{ Intent var2 =(新的this.startActivityForResult(var2,1);} catch (GooglePlayServicesRepairableException var3) { var1 = var3.getConnectionStatusCode();Log.e(“Place”,“未能打开自动完成的活动”,var3);} catch (GooglePlayServicesNotAvailableException var4) { var1 = var4.errorCode;Log.e("Places",“未能打开自动完成的活动”,var4);} if (var1 != -1) { GoogleApiAvailability var5 = GoogleApiAvailability.getInstance(); 另外,如果您有任何这些解决方案的问题,请给我一个反馈。
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/41336736

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档