Refresh ListView upon Tab change/swipe (Android)

 ̄綄美尐妖づ 提交于 2019-12-25 05:07:07

问题


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?

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.

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

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

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


回答1:


Think I answered my own question:

I have this code

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

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


}


来源:https://stackoverflow.com/questions/11495658/refresh-listview-upon-tab-change-swipe-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!