• <bdo id='FBtgk'></bdo><ul id='FBtgk'></ul>

  • <tfoot id='FBtgk'></tfoot>
  • <small id='FBtgk'></small><noframes id='FBtgk'>

      <legend id='FBtgk'><style id='FBtgk'><dir id='FBtgk'><q id='FBtgk'></q></dir></style></legend>
        <i id='FBtgk'><tr id='FBtgk'><dt id='FBtgk'><q id='FBtgk'><span id='FBtgk'><b id='FBtgk'><form id='FBtgk'><ins id='FBtgk'></ins><ul id='FBtgk'></ul><sub id='FBtgk'></sub></form><legend id='FBtgk'></legend><bdo id='FBtgk'><pre id='FBtgk'><center id='FBtgk'></center></pre></bdo></b><th id='FBtgk'></th></span></q></dt></tr></i><div id='FBtgk'><tfoot id='FBtgk'></tfoot><dl id='FBtgk'><fieldset id='FBtgk'></fieldset></dl></div>

        SupportPlaceAutocompleteFragment 的 OnPlaceSelectedListener 未

        OnPlaceSelectedListener of SupportPlaceAutocompleteFragment not fired(SupportPlaceAutocompleteFragment 的 OnPlaceSelectedListener 未触发)
      1. <i id='Mjg2b'><tr id='Mjg2b'><dt id='Mjg2b'><q id='Mjg2b'><span id='Mjg2b'><b id='Mjg2b'><form id='Mjg2b'><ins id='Mjg2b'></ins><ul id='Mjg2b'></ul><sub id='Mjg2b'></sub></form><legend id='Mjg2b'></legend><bdo id='Mjg2b'><pre id='Mjg2b'><center id='Mjg2b'></center></pre></bdo></b><th id='Mjg2b'></th></span></q></dt></tr></i><div id='Mjg2b'><tfoot id='Mjg2b'></tfoot><dl id='Mjg2b'><fieldset id='Mjg2b'></fieldset></dl></div>

          <legend id='Mjg2b'><style id='Mjg2b'><dir id='Mjg2b'><q id='Mjg2b'></q></dir></style></legend>
            <bdo id='Mjg2b'></bdo><ul id='Mjg2b'></ul>

            <small id='Mjg2b'></small><noframes id='Mjg2b'>

                1. <tfoot id='Mjg2b'></tfoot>
                    <tbody id='Mjg2b'></tbody>

                  本文介绍了SupportPlaceAutocompleteFragment 的 OnPlaceSelectedListener 未触发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  SupportPlaceAutocompleteFragmentOnPlaceSelectedListener 方法有问题.

                  我的 onViewCreated() 方法:

                  @Override
                  public void onViewCreated(View view, Bundle savedInstanceState) {
                      super.onViewCreated(view, savedInstanceState);
                  
                      // Initialise a new fragment inside of this one.
                      mFragmentManager = getChildFragmentManager();
                      mSupportMapFragment = (SupportMapFragment) mFragmentManager.findFragmentByTag("mapFragment");
                      mSupportPlaceAutocompleteFragment = (SupportPlaceAutocompleteFragment) mFragmentManager.findFragmentByTag("autocompleteFragment");
                  
                      // Never inflate fragments inside other fragments in a layout.xml!
                      // Do it programmatically.
                      // See here for reference: https://stackoverflow.com/a/19815266/4938112.
                      if (mSupportMapFragment == null) {
                          mSupportMapFragment = new SupportMapFragment();
                          fragmentTransaction(mFragmentManager, mSupportMapFragment, R.id.map_fragment_container, "mapFragment");
                      }
                  
                      // Asynchronous thread to load map.
                      mSupportMapFragment.getMapAsync(this);
                  
                  
                      if (mSupportPlaceAutocompleteFragment == null) {
                          mSupportPlaceAutocompleteFragment = new SupportPlaceAutocompleteFragment();
                          fragmentTransaction(mFragmentManager, mSupportPlaceAutocompleteFragment, R.id.card_view, "autocompleteFragment");
                      }
                  
                      // Filter for a specific place type.
                      AutocompleteFilter typeFilter = new AutocompleteFilter.Builder()
                              .setTypeFilter(AutocompleteFilter.TYPE_FILTER_CITIES)
                              .build();
                      mSupportPlaceAutocompleteFragment.setFilter(typeFilter);
                  
                      Log.d("I'M HERE", "Hello.");
                  
                      mSupportPlaceAutocompleteFragment.setOnPlaceSelectedListener(new PlaceSelectionListener() {
                          @Override
                          public void onPlaceSelected(Place place) {
                              // TODO: Get info about the selected place.
                              Log.i("PLACE", "Place: " + place.getName());
                              int flag = 1;
                              Log.d("FLAG", "flag: " + flag);
                          }
                  
                          @Override
                          public void onError(Status status) {
                              // TODO: Handle the error.
                              Log.i("PLACE_ERROR", "An error occurred: " + status);
                              int flag = 0;
                              Log.d("FLAG", "flag: " + flag);
                          }
                      });
                  
                      Log.d("I'M HERE, TOO", "Hello.");
                  
                  }
                  

                  当我选择一个地点(所有 API 都已启用并且我有一个 Google 密钥)时,AutoCompleteFragment 刚刚关闭,地图上没有任何反应.mSupportPlaceAutocompleteFragment.setOnPlaceSelectedListener(...) 方法未被触发.

                  When I select a place (all the APIs are enabled and I've a Google Key), the AutoCompleteFragment just closed and nothing happens on the map. The mSupportPlaceAutocompleteFragment.setOnPlaceSelectedListener(...) method is not being fired.

                  有什么提示吗?

                  我的问题类似于 this question 中的问题.

                  My problem is similar to the one in this question.

                  我也在使用嵌套片段,我无法理解在这种情况下如何查看 onActivityResult() 方法.

                  I'm using nested fragments, too and I can't understand how to see the onActivityResult() method in this case.

                  推荐答案

                  终于解决了这个问题:希望对大家有所帮助.

                  Finally solved this problem: hope it will help someone.

                  我在我的 MainActivity 的 onActivityResult() 方法中添加了这条臭名昭著的行

                  I added this infamous line in the onActivityResult() method in my MainActivity

                  @Override
                  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
                      super.onActivityResult(requestCode, resultCode, data);
                  
                      ...
                  }
                  

                  然后确实在我的 MapFragment 中放入了相同的方法

                  and then did put the same method in my MapFragment

                      @Override
                  public void onActivityResult(int requestCode, int resultCode, Intent data) {
                      super.onActivityResult(requestCode, resultCode, data);
                  }
                  

                  现在嵌套片段正在发回其数据.

                  Now the nested fragment is sending back its data.

                  这篇关于SupportPlaceAutocompleteFragment 的 OnPlaceSelectedListener 未触发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  How can I use CClistview in COCOS2d Android?(如何在 COCOS2d Android 中使用 CClistview?)
                  cocos2d-android: how to display score(cocos2d-android:如何显示分数)
                  Sqlite database not copied from asset folder Android(Sqlite 数据库未从资产文件夹 Android 复制)
                  SQLite Database Copy Appears Corrupted When Generated by Device and not Emulator(SQLite 数据库副本在由设备而不是模拟器生成时出现损坏)
                  Android file copy(安卓文件拷贝)
                  Android how to detect Copy event of Edittext in android(Android如何在android中检测Edittext的Copy事件)

                    <legend id='FlLvW'><style id='FlLvW'><dir id='FlLvW'><q id='FlLvW'></q></dir></style></legend>
                    <i id='FlLvW'><tr id='FlLvW'><dt id='FlLvW'><q id='FlLvW'><span id='FlLvW'><b id='FlLvW'><form id='FlLvW'><ins id='FlLvW'></ins><ul id='FlLvW'></ul><sub id='FlLvW'></sub></form><legend id='FlLvW'></legend><bdo id='FlLvW'><pre id='FlLvW'><center id='FlLvW'></center></pre></bdo></b><th id='FlLvW'></th></span></q></dt></tr></i><div id='FlLvW'><tfoot id='FlLvW'></tfoot><dl id='FlLvW'><fieldset id='FlLvW'></fieldset></dl></div>

                    <small id='FlLvW'></small><noframes id='FlLvW'>

                  1. <tfoot id='FlLvW'></tfoot>
                        <tbody id='FlLvW'></tbody>
                          <bdo id='FlLvW'></bdo><ul id='FlLvW'></ul>