Java Code Examples for android.support.v4.view.PagerAdapter#notifyDataSetChanged()
The following examples show how to use
android.support.v4.view.PagerAdapter#notifyDataSetChanged() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ViewPagerAdapter.java From MVVM-JueJin with MIT License | 6 votes |
private static void bind(ViewPager container, final ItemView itemView, final List<?> datas, final OnItemClickListener<?> onItemClickListener) { PagerAdapter adapter; if (datas != null && !datas.isEmpty()) { adapter = container.getAdapter(); if(adapter == null) { // initialize, adapter is only set once !!! container.setAdapter(adapter = new CommonPagerAdapter<Object>(container.getContext(), itemView.layoutRes(), (List<Object>)datas) { @Override protected void convert(ViewHolder holder, Object data, int position) { DataBindingUtil.bind(holder.itemView).setVariable(itemView.bindingVariable(), data); } }); ((CommonPagerAdapter<Object>)adapter).setOnItemClickListener((OnItemClickListener<Object>)onItemClickListener); } adapter.notifyDataSetChanged(); } }
Example 2
Source File: RtlViewPager.java From IslamicLibraryAndroid with GNU General Public License v3.0 | 6 votes |
@Override public void onRtlPropertiesChanged(int layoutDirection) { super.onRtlPropertiesChanged(layoutDirection); int viewCompatLayoutDirection = layoutDirection == View.LAYOUT_DIRECTION_RTL ? ViewCompat.LAYOUT_DIRECTION_RTL : ViewCompat.LAYOUT_DIRECTION_LTR; if (viewCompatLayoutDirection != mLayoutDirection) { PagerAdapter adapter = super.getAdapter(); int position = 0; if (adapter != null) { position = getCurrentItem(); } mLayoutDirection = viewCompatLayoutDirection; if (adapter != null) { adapter.notifyDataSetChanged(); setCurrentItem(position); } } }
Example 3
Source File: FragmentAdapter.java From MVVM-JueJin with MIT License | 5 votes |
@BindingAdapter(value = {"fragments", "curIndex"}, requireAll = false) public static void bind(ViewPager container, final List<? extends Fragment> fragments, int curIndex) { if(!(container.getContext() instanceof FragmentActivity)) throw new IllegalArgumentException(TAG + "context must instanceof FragmentActivity"); FragmentManager fm = ((FragmentActivity) container.getContext()).getSupportFragmentManager(); if (fragments != null && !fragments.isEmpty()) { PagerAdapter adapter = container.getAdapter(); if(adapter == null) { // initialize, fragments are only added once !!! container.setAdapter(adapter = new FragmentPagerAdapter(fm) { @Override public Fragment getItem(int position) { return fragments.get(position); } @Override public int getCount() { return fragments.size(); } }); } adapter.notifyDataSetChanged(); if(curIndex >= 0 && curIndex < fragments.size()) container.setCurrentItem(curIndex); } }
Example 4
Source File: PagerAdapterTags.java From rss with GNU General Public License v3.0 | 5 votes |
public static void run(FeedsActivity activity) { s_tagList = getTagsFromIndex(activity, activity.m_index); PagerAdapter adapter = s_viewPager.getAdapter(); adapter.notifyDataSetChanged(); }