使用Intent跨Activity传值

下面是在一个Activity中


        Intent intent = new Intent(mContext, ImagePagerActivity.class);
        intent.putExtra(ImagePagerActivity.EXTRA_IMAGE_URLS, urls2);
        intent.putExtra(ImagePagerActivity.EXTRA_IMAGE_INDEX, position);
        mContext.startActivity(intent);

获取上一个Activity中传过来的值

    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.image_detail_pager);

        pagerPosition = getIntent().getIntExtra(EXTRA_IMAGE_INDEX, 0);
        ArrayList urls = getIntent().getStringArrayListExtra(EXTRA_IMAGE_URLS);


FR:海涛高软(徐海涛)

你可能感兴趣的:(Android)