刷新ListView控件在Tab切换/滑动(Android版) [英] Refresh ListView upon Tab change/swipe (Android)

查看:425
本文介绍了刷新ListView控件在Tab切换/滑动(Android版)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个片段和FragmentActivitiy下ListFragment两者。当我在片段,我想刷到ListFragment,我怎么在ListView更新?

I have a Fragment and a ListFragment both under a FragmentActivitiy. When I am in the Fragment, and I want to swipe to the ListFragment, how do I get the ListView to update?

基本上,我有一个插入按钮/ EditText上的片段,用户将插入新的信息。我想刷到ListFragment,然后动态地看到,新的信息。得到它刷新的唯一方法是通过取消父活动,并再次输入。

Basically, I have an insert button/EditText in the Fragment and the user will insert new info. I want to swipe to the ListFragment and then dynamically SEE that new info. The only way to get it to refresh is by backing out of the parent activity and entering again.

我看到有方法onTabSelected或onTabReselected,不知道这是你做的?

I see there are methods onTabSelected or onTabReselected, not sure if this is where you do it?

难道涉及典型的codeAdapter.notifyDataSetChanged()?

Would it involve the typical code "Adapter.notifyDataSetChanged()"?

编辑:我想也许我只需要了解如何更新一般片段视图

I am thinking maybe I just need to see how you can update a Fragment view in general?

推荐答案

我想我回答我自己的问题:

Think I answered my own question:

我有这样的code

public void onTabSelected(ActionBar.Tab tab, FragmentTransaction ft) {

    mViewPager = (ViewPager) findViewById(R.id.viewpager);
    mViewPager.setAdapter(mSectionsPagerAdapter);


}

这篇关于刷新ListView控件在Tab切换/滑动(Android版)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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