android上下文之间参数的传递与接…

接收方:
Intent intent = getIntent();
Bundle b = intent.getExtras();
if(b.containsKey("entries")) {
    mImageList = (ArrayList) b.getSerializable("entries");
}
else if(b.containsKey("favorites")) {
    mFavoriteList = (ArrayList) b.getSerializable("favorites");
    btnFavorite.setImageResource(R.drawable.icon_delete);        }
tag_index = intent.getIntExtra("tag", 0);
mPosition = intent.getIntExtra("position", 0);
mViewPager.setCurrentItem(mPosition, false);


传递方:
Intent intent = new Intent();
Bundle b = new Bundle();
b.putInt("position", position);
b.putSerializable("entries", indexes);
b.putInt("tag", tag);
intent.putExtras(b);
intent.setClass(context, ImageTouchActivity.class);
context.startActivity(intent);

你可能感兴趣的:(android)