错误选项卡中的进度对话框 [英] progressDialog in wrong tab

查看:45
本文介绍了错误选项卡中的进度对话框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序中有 4 个选项卡.其中之一是使用进度对话框进行 json 解析.但我在另一个选项卡上看到进度对话框.

I have 4 tabs in my application. One of them is for json parsing with progress dialog. But i see progres dialog at another tab.

    @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    View view = inflater.inflate(R.layout.fragment_parsing, container, false);
    lv = (ListView)view.findViewById(R.id.list);
    progressDialog = ProgressDialog.show(lv.getContext(), null, getResources().getString(R.string.connecting), true, true);
    MyTask myTask = new MyTask(FragmentParsing.this);
    myTask.execute(url);

    return view;
}

    @Override
public void onTaskComplete(ArrayList<String> array) {
    if(array != null) {
        //adapter.clear();
        arrayList.addAll(array);
        adapter = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_list_item_1, arrayList);
        lv.setAdapter(adapter);
        adapter.notifyDataSetChanged();
    }
    else
        Toast.makeText(getView().getContext(), getResources().getString(R.string.fuck), Toast.LENGTH_SHORT).show();
    if (progressDialog != null && progressDialog.isShowing()) {
        progressDialog.dismiss();
    }
}

我想在文本左侧看到图标.不在上面.

And i want to see icons to left of text. Not above.

来自 MainActivity 的代码

Code from MainActivity

private void setUI(){
        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        if (toolbar != null){
            toolbar.setTitleTextColor(getResources().getColor(R.color.white));
            setSupportActionBar(toolbar);
        }
        TabLayout tabLayout = (TabLayout) findViewById(R.id.tab_layout);
        tabLayout.addTab(tabLayout.newTab().setIcon(R.drawable.ic_list_white_18dp).setText(R.string.listtab));
        tabLayout.addTab(tabLayout.newTab().setIcon(R.drawable.ic_camera_alt_white_18dp).setText(R.string.scalingtab));
        tabLayout.addTab(tabLayout.newTab().setIcon(R.drawable.ic_web_asset_white_18dp).setText(R.string.parsingtab));
        tabLayout.addTab(tabLayout.newTab().setIcon(R.drawable.ic_my_location_white_18dp).setText(R.string.maptab));

        final ViewPager viewPager = (ViewPager) findViewById(R.id.pager);
        TabAdapter tabAdapter = new TabAdapter(fragmentManager, 4);
        viewPager.setAdapter(tabAdapter);
        viewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout));

        tabLayout.setOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
            @Override
            public void onTabSelected(TabLayout.Tab tab) {
                viewPager.setCurrentItem(tab.getPosition());
            }

            @Override
            public void onTabUnselected(TabLayout.Tab tab) {

            }

            @Override
            public void onTabReselected(TabLayout.Tab tab) {

            }
        });
    }

推荐答案

它基本上是 android pager 工作流程.只要您滑动,它总是会创建一个相邻的页面视图.你可以有记录器和检查.如果我没有弄错您的片段寻呼机,您可以在片段的 onResume callback 上启动进度条.

Its basically android pager workflow. It always creates one adjacent page view as soon as you swipe. You can have logger and check. If I'm not not wrong your fragment pager, you start your progress bar on onResume callback of your fragment.

这篇关于错误选项卡中的进度对话框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆