相关疑难解决方法(0)

如何在片段中设置ViewPager

我需要在一个片段中放置一个ViewPager,但我有两个片段,片段1是我的菜单,片段2我想用作ViewPagerIndicator.

但是片段不能有另一个片段......我需要做些什么呢?

在此输入图像描述

android android-fragments android-viewpager android-nested-fragment

45
推荐指数
3
解决办法
7万
查看次数

Android ViewPager和TabLayout运行速度不快

有嵌套片段TabLayoutViewPager.每个片段里面都有listview,所以他们可以一起调用,现在我遇到了app处理速度慢的问题.我尝试过一些像凌空图书馆这样的解决方案,但它对我不起作用.更多我发布我的代码所以请指导我做到最好.

MainTabFragment.java

public class MainTabFragment extends Fragment {

public static int position_child_tab = 0, three_childs_tab_position = 0;
static int count = -1;
int position_tab = 0;
Bundle args;
MyTabLayout myTabLayout;

public MainTabFragment() {
    // Required empty public constructor
}

/**
 * Use this factory method to create a new instance of
 * this fragment using the provided parameters.
 *
 * @param param1 Parameter 1.
 * @param param2 Parameter 2.
 * @return A new instance of fragment …
Run Code Online (Sandbox Code Playgroud)

performance android android-fragments android-viewpager android-tablayout

23
推荐指数
2
解决办法
5854
查看次数

Android TabLayout没有重新加载片段

我注意到TabLayout它只Fragments需要显示一次,所以当我替换Fragment包含TabLayout并切换回它时,它不会重新创建Fragments它保持,因此它们不再显示任何内容.是这样的设计还是我做错了什么?我Fragment在a中使用外部NavigationDrawer,当用户切换到另一个Fragment并返回时,该选项卡Fragments为空,因为它们不会被重新创建.我还注意到在切换回包含它们的片段后,Tabs的行为非常奇怪(它们在跳跃下面的白线,你可以在两个标签之间保持它而不触摸屏幕)

我正在使用的代码:

public class Fragment1 extends Fragment {
    private static ViewPager viewPager;
    private static TabLayout tabLayout;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        Utils.changeLanguage(getActivity());

        final Context contextThemeWrapper = new ContextThemeWrapper(getActivity(), R.style.LinesOverlay);

        LayoutInflater localInflater = inflater.cloneInContext(contextThemeWrapper);

        View view = localInflater.inflate(R.layout.fragment1, container, false);
        viewPager = (ViewPager) view.findViewById(R.id.viewpager);
        tabLayout = (TabLayout) view.findViewById(R.id.tabs);

        return view;
    }

    @Override
    public void onActivityCreated(Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState); …
Run Code Online (Sandbox Code Playgroud)

android android-fragments android-tabs navigation-drawer androiddesignsupport

7
推荐指数
1
解决办法
1763
查看次数