我使用 viewpagerindicator,在启动这个活动时,看起来所有片段都在加载。我想要一个片段启动刚刚打开、单击或滑动并进行加载。并且未打开的片段会在打开时加载,稍后单击或滑动。如何?
这是我的代码适配器 viewpager
import android.content.Context;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
public class ViewAdapter extends FragmentPagerAdapter{
private Context _context;
String[] page_titles;
public ViewAdapter(Context context, FragmentManager fm, String[] page_title){
super(fm);
_context = context;
this.page_titles = page_title;
}
@Override
public Fragment getItem(int position) {
// TODO Auto-generated method stub
Fragment f = new Fragment();
switch(position){
case 0:
f = ContentActivity.newInstance(_context);
break;
case 1:
f = ContentActivity.newInstance(_context);
break;
case 2:
f = ContentActivity.newInstance(_context);
break;
}
return f;
}
@Override
public int getCount() {
// TODO Auto-generated method stub
return page_titles.length;
}
public CharSequence getPageTitle(int position) {
return page_titles[position];
}
}
对不起我的英语不好..