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

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

        <legend id='zcyIg'><style id='zcyIg'><dir id='zcyIg'><q id='zcyIg'></q></dir></style></legend>

        我可以将视图寻呼机与视图一起使用(而不是片段)

        时间:2023-10-04

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

            <tbody id='eo43u'></tbody>
            <bdo id='eo43u'></bdo><ul id='eo43u'></ul>
              <legend id='eo43u'><style id='eo43u'><dir id='eo43u'><q id='eo43u'></q></dir></style></legend>
            • <i id='eo43u'><tr id='eo43u'><dt id='eo43u'><q id='eo43u'><span id='eo43u'><b id='eo43u'><form id='eo43u'><ins id='eo43u'></ins><ul id='eo43u'></ul><sub id='eo43u'></sub></form><legend id='eo43u'></legend><bdo id='eo43u'><pre id='eo43u'><center id='eo43u'></center></pre></bdo></b><th id='eo43u'></th></span></q></dt></tr></i><div id='eo43u'><tfoot id='eo43u'></tfoot><dl id='eo43u'><fieldset id='eo43u'></fieldset></dl></div>
              1. <tfoot id='eo43u'></tfoot>
                • 本文介绍了我可以将视图寻呼机与视图一起使用(而不是片段)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我使用 ViewPagerFragments 之间滑动,但是我可以使用 ViewPagerViews 之间滑动吗?XML 布局?

                  I am using ViewPager for swiping between Fragments, but can I use ViewPager to swipe between Views simple XML layout?

                  这是我的页面 Adapter 用于在 Fragments 之间滑动的 ViewPager:

                  This is my page Adapter for the ViewPager which is used to swipe between Fragments:

                  import java.util.List;
                  
                  import com.app.name.fragments.TipsFragment;
                  
                  import android.support.v4.app.Fragment;
                  import android.support.v4.app.FragmentManager;
                  import android.support.v4.app.FragmentPagerAdapter;
                  import android.support.v4.app.FragmentTransaction;
                  import android.view.ViewGroup;
                  
                  public class PageAdapter extends FragmentPagerAdapter {
                  
                      /**
                       *
                       */
                      List<Fragment> fragments;
                      public PageAdapter(FragmentManager fm,List<Fragment> frags) {
                          super(fm);
                          fragments = frags;
                  
                      }
                  
                      @Override
                      public Fragment getItem(int arg0) {
                          // TODO Auto-generated method stub
                          return TipsFragment.newInstance(0, 0);
                      }
                  
                      @Override
                      public int getCount() {
                          // TODO Auto-generated method stub
                          return 4;
                      }
                  
                      @Override
                      public void destroyItem(ViewGroup container, int position, Object object) {
                          FragmentManager manager = ((Fragment) object).getFragmentManager();
                          FragmentTransaction trans = manager.beginTransaction();
                          trans.remove((Fragment) object);
                          trans.commit();
                  
                          super.destroyItem(container, position, object);
                      }
                  
                  }
                  

                  这是我的提示片段:

                  public class TipsFragment extends Fragment
                  {
                      public static TipsFragment newInstance(int image,int content)
                      {
                          TipsFragment fragment = new TipsFragment();
                          return fragment;
                      }
                  
                      @Override
                      public View onCreateView(LayoutInflater inflater, ViewGroup container,
                                               Bundle savedInstanceState) {
                          View view = inflater.inflate(R.layout.tip_layout, null);
                          return view;
                      }
                  }
                  

                  如何修改我的代码以使用视图而不是片段?

                  How can I modify my code to work with Views instead of Fragment?

                  推荐答案

                  你需要重写这两个方法而不是getItem():

                  You need to override these two methods rather than getItem():

                  @Override
                  public Object instantiateItem(ViewGroup collection, int position) {
                      View v = layoutInflater.inflate(...);
                      ...
                      collection.addView(v,0);
                      return v;
                  }
                  
                  @Override
                  public void destroyItem(ViewGroup collection, int position, Object view) {
                      collection.removeView((View) view);
                  }
                  

                  这篇关于我可以将视图寻呼机与视图一起使用(而不是片段)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:您如何获取 Android 版 ViewPager 的当前页码? 下一篇:Android.app Fragments 与 android.support.v4.app 使用 ViewPager?

                  相关文章

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

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

                      <legend id='YqKOv'><style id='YqKOv'><dir id='YqKOv'><q id='YqKOv'></q></dir></style></legend>
                      <tfoot id='YqKOv'></tfoot>