<bdo id='oy4EV'></bdo><ul id='oy4EV'></ul>
  • <tfoot id='oy4EV'></tfoot>
        <legend id='oy4EV'><style id='oy4EV'><dir id='oy4EV'><q id='oy4EV'></q></dir></style></legend>

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

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

        带有 viewPager 的地图 V2

        时间:2023-10-04
        <i id='UzePU'><tr id='UzePU'><dt id='UzePU'><q id='UzePU'><span id='UzePU'><b id='UzePU'><form id='UzePU'><ins id='UzePU'></ins><ul id='UzePU'></ul><sub id='UzePU'></sub></form><legend id='UzePU'></legend><bdo id='UzePU'><pre id='UzePU'><center id='UzePU'></center></pre></bdo></b><th id='UzePU'></th></span></q></dt></tr></i><div id='UzePU'><tfoot id='UzePU'></tfoot><dl id='UzePU'><fieldset id='UzePU'></fieldset></dl></div>

      1. <legend id='UzePU'><style id='UzePU'><dir id='UzePU'><q id='UzePU'></q></dir></style></legend>

          <bdo id='UzePU'></bdo><ul id='UzePU'></ul>
          • <small id='UzePU'></small><noframes id='UzePU'>

              <tbody id='UzePU'></tbody>

                  <tfoot id='UzePU'></tfoot>
                • 本文介绍了带有 viewPager 的地图 V2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我目前正在为 Android 4.3 开发.
                  背景:
                  我正在使用 pageViewer 在三个不同的片段之间滚动.我的第二个片段(选项卡 2)包含带有 SupportMapFragment 和其他内容的 XML.如下图:
                  我的问题http://imageupload.co.uk/files/vrhg1e06x977rkm1vhmd.jpg
                  我的尝试:
                  在搜索网络时,我注意到 SupportMapFragment 我需要 FragmentActivity,它不适用于 FragmentPagerAdapter.我需要用户能够控制地图以及控制片段中的其余内容.
                  我的问题:
                  如何在片段中有更多内容的同时将 SupportMapFragment 与 viewPager 一起使用?

                  I'm currently developing for Android 4.3.
                  Background:
                  I'm using pageViewer to scroll between three different fragments. My second fragment (tab 2) has XML with SupportMapFragment and other content. as shown below :
                  My problem http://imageupload.co.uk/files/vrhg1e06x977rkm1vhmd.jpg
                  My Attempt:
                  While searching the web I noticed that for SupportMapFragment I need FragmentActivity which doesn't apply for FragmentPagerAdapter. I need the user to have the ability to control the map as well as control the rest of the content in the fragment.
                  My Question:
                  How can I use the SupportMapFragment with the viewPager while having more content in the Fragment?

                  更多关于我的代码:在 FragmentPagerAdapter 内的 getItem 中,我返回单例片段(每个片段都有一个类),因此我无法通过 Internet 找到任何解决方案,因为我的类无法扩展 SupportMapFragment,因为它有更多数据.

                  More about my code: in the getItem inside FragmentPagerAdapter I'm returning Singleton Fragments (each Fragment has a class) therefore I couldn't find any solution over the Internet since my class can't extend SupportMapFragment because it has more data.

                  推荐答案

                  从 Android 4.2 开始(也在 pre-Jelly 的支持库中)你可以使用 嵌套片段.

                  Since Android 4.2 (also in the support library for pre-Jelly) you can use nested fragments.

                  你可以看到如何创建这样的片段是:

                  You can see how to create such fragment is:

                  public class MyFragment extends Fragment {
                  
                      private SupportMapFragment fragment;
                      private GoogleMap map;
                  
                      @Override
                      public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
                          return inflater.inflate(R.layout.layout_with_map, container, false);
                      }
                  
                      @Override
                      public void onActivityCreated(Bundle savedInstanceState) {
                          super.onActivityCreated(savedInstanceState);
                          FragmentManager fm = getChildFragmentManager();
                          fragment = (SupportMapFragment) fm.findFragmentById(R.id.map_container);
                          if (fragment == null) {
                              fragment = SupportMapFragment.newInstance();
                              fm.beginTransaction().replace(R.id.map_container, fragment).commit();
                          }
                      }
                  
                      @Override
                      public void onResume() {
                          super.onResume();
                          if (map == null) {
                              map = fragment.getMap();
                              map.addMarker(new MarkerOptions().position(new LatLng(0, 0)));
                          }
                      }
                  }
                  

                  以上代码从此处复制而来.

                  重要提示:您的自定义 Fragments 的布局不能包含 <fragment> 标记.

                  Impoatant note: your custom Fragments's layout cannot contain <fragment> tag.

                  这篇关于带有 viewPager 的地图 V2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:AdMob AdView 和 ViewPager? 下一篇:ListView 行内的 ViewPager 防止 onItemClick 被触发

                  相关文章

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

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

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

                      <tfoot id='rKw5w'></tfoot>