我有一个包含项目苹果,香蕉,橙色的列表视图...在第二个屏幕活动中,当我点击苹果上的特定项目时,它导航到详细信息屏幕
这里的输出必须看起来像苹果..如果我滑动页面然后是香蕉,然后是 nextswipe orage
苹果-->香蕉-->橙子
但是我得到了像apple-->apple-->apple这样的输出。
Intent detailIntent =new Intent(SecondScreen.this, Details.class);
startActivity(detailIntent);
public class MyApplication extends Application {
ArrayList<String> totalvalue = new ArrayList<String>();
}
public class Details extends FragmentActivity{
MyApplication app;
ViewPager pager;
MyFragmentPagerAdapter pagerAdapter;
public static int position ;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.detail);
app = ((MyApplication) getApplicationContext());
pager = (ViewPager) findViewById(R.id.pager);
FragmentManager fm = getSupportFragmentManager();
pagerAdapter = new MyFragmentPagerAdapter(fm,app.totalvalue);
pager.setAdapter(pagerAdapter);
}
public static class MyFragmentPagerAdapter extends FragmentPagerAdapter {
private static ArrayList<String> temperList;
public MyFragmentPagerAdapter(FragmentManager fm, ArrayList<String> totalvalue ) {
super(fm);
this.temperList = totalvalue;
}
public Fragment getItem(int position) {
return ThingFragment.newInstance((temperList.get(position)));
}
@Override
public int getCount(){
return temperList.size();
}
private static class ThingFragment extends Fragment {
private String name1;
static ThingFragment newInstance(String string ) {
ThingFragment f = new ThingFragment();
Bundle args = new Bundle();
args.putString("name",temperList.get(position) );
f.setArguments(args);
return f;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
name1 = getArguments().getString("name");
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.myfragment_layout, container, false);
TextView t = (TextView)v.findViewById(R.id.prodcutt);
t.setText(""+ name1);
return v;
}
}
}
}