android-pageradapter

How do I implement view recycling mechanism for PagerAdapter?

梦想与她 提交于 2019-11-28 07:16:27
I have a pager adapter that suppose to inflate a complex view representing a calendar. It takes around ~350 ms to inflate each year of the calendar. To improve performance I would like to implement the same mechanism that exists in the ListView array adapter of recycling views ( convertView parameter in getView() ). Here is my current getView() from the adapter. @Override protected View getView(VerticalViewPager pager, final DateTileGrid currentDataItem, int position) { mInflater = LayoutInflater.from(pager.getContext()); // This is were i would like to understand weather is should use a

Correctly implementing PagerAdapter in Android

走远了吗. 提交于 2019-11-27 05:49:03
问题 I have problems with implementation of my custom PagerAdapter and using it with a ViewPager. This sample PagerAdapter has 10 items, every item is a button with it's index as text. When I run my program, I see a button with text '1' insted of '0'. And when I swipe to other items I get only blank views. When I swipe backwards sometimes I see a button with some number, but it disappears (maybe it is destroying and I remove it from the container), and sometimes I see a button with a number, but

Android: FragmentPagerAdapter: getItem method called twice on First time

旧城冷巷雨未停 提交于 2019-11-27 02:06:30
问题 In My application, I have used the ViewPager. Like, (say main.xml) <android.support.v4.view.ViewPager android:id="@+id/viewPager" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_above="@+id/register_header" /> And Create ViewPager object and ViewPagerAdapter(which extends FragmentPagerAdapter) object in FragmentActivity. _mViewPager = (ViewPager) findViewById(R.id.viewPager); _adapter = new ViewPagerAdapter(getApplicationContext(),