
package com.creatiosoft.RSSFeed.adaptor; import androID.content.Context; import androID.support.v4.app.Fragment; import androID.support.v4.app.FragmentManager; import androID.support.v4.app.FragmentPagerAdapter; import androID.util.Log; import com.creatiosoft.RSSFeed.utils.RSSItem; import com.vIEwpagerindicator.IconPagerAdapter; public class NewsFeedsAdapter extends FragmentPagerAdapter implements IconPagerAdapter { int[] icon = null; String[] content = null; String[] URLs = null; Context cont; public NewsFeedsAdapter(FragmentManager fm,Context context) { super(fm); Log.i("jk","constructor"); this.cont = context; RSSItem newsFeedAppliaction = (RSSItem) cont; /* * RetrIEving the values of the Icons and contents from the application * class in utils package */ icon = newsFeedAppliaction.getICONS(); content = newsFeedAppliaction.getCONTENT(); URLs = newsFeedAppliaction.getURL(); } /** instantiate a new fragment class */ @OverrIDe public Fragment getItem(int position) { Log.i("yt","hello" + position); return TestFragment.newInstance(position % content.length,cont); } @OverrIDe public CharSequence getPageTitle(int position) { return content[position % content.length].toupperCase(); } public int getIconResID(int index) { return icon[index]; } /** return the no of vIEws on the basis of array items */ @OverrIDe public int getCount() { Log.i("hi","length" + content.length); return content.length; } }@H_301_3@ 我用这段代码调用Adapter:
NewsFeedsAdapter adapter = new NewsFeedsAdapter( getSupportFragmentManager(),getApplicationContext()); /** * get the ID of the vIEw pager declared in the xml resource and set the * adaptor on the vIEw pager */ VIEwPager pager = (VIEwPager) findVIEwByID(R.ID.pager); pager.setAdapter(adapter); //pager.setCurrentItem(0); /** * Tab page indicator class is used to indicate the tabs and is accessed * from the library class */ TabPageIndicator indicator = (TabPageIndicator) findVIEwByID(R.ID.indicator); indicator.setVIEwPager(pager);@H_301_3@解决方法 请注意,寻呼机至少保持一页.这意味着当创建寻呼机时,他创建至少两个页面 – 他显示的页面和下一个页面,以便允许“分页”. 总结 以上是内存溢出为你收集整理的使用Fragment Pager Adapter时,android-getItem()方法被调用两次全部内容,希望文章能够帮你解决使用Fragment Pager Adapter时,android-getItem()方法被调用两次所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)