当从 activity 接收字符串列表数据时,它给出空输出

It gives null output when receive string list data from an activity

我有两个字符串列表要从 android 中的适配器发送到 activity。

我的适配器中有这两个数组,

 private final List<String> toppingPriceTop;
 private final List<String> toppingDescriptionTop;

在我的适配器中我有这个按钮,点击这个按钮将这些详细信息发送到 activity,

customize.setOnClickListener(new View.OnClickListener(){
            @Override
            public void onClick(View view) {

                Intent next = new Intent(context, ActivityCustomize.class);

                next.putExtra("description", descriptions.get(position));
                next.putExtra("imageUrl", imageUrls.get(position));

                next.putExtra("toppingDescriptionTop", toppingDescriptionTop.get(position));
                next.putExtra("toppingPriceTop", toppingPriceTop.get(position));

                context.startActivity(next);
                ((Activity) context).overridePendingTransition(
                        R.anim.slide_in_right, R.anim.slide_out_left);
            }

在我的 activity 中,我收到这些数据,

String [] toppingPriceTop = getIntent().getStringArrayExtra("toppingPriceTop");
String [] toppingDescriptionTop = getIntent().getStringArrayExtra("toppingDescriptionTop");
String imageUrl = getIntent().getStringExtra("imageUrl");
String  description = getIntent().getStringExtra("description");

我的问题是我在 activity 中获取 imageUrl 和描述的值,但对于两个列表数组,我得到的都是空值。任何人都告诉我哪里出了问题,请问我该如何纠正。 任何帮助将不胜感激。

照做

 next.putStringArrayListExtra("toppingDescriptionTop", toppingDescriptionTop);
 next.putStringArrayListExtra("toppingPriceTop", toppingPriceTop);

你应该通过所有 List

喜欢

List<String> toppingPriceTop = getIntent().getStringArrayListExtra("toppingPriceTop");
List<String> toppingDescriptionTop = getIntent().getStringArrayListExtra("toppingDescriptionTop");

照做

 Bundle b=new Bundle();
 b.putStringArrayListExtra("toppingPriceTop ", toppingPriceTop);
 b.putStringArrayListExtra("toppingDescriptionTop", toppingDescriptionTop);
 next.putExtras(extras)
 context.startActivity(next);

并得到它:

 Bundle b=getIntent().getExtras();
 ArrayList<String> toppingPriceTop =b.getStringArrayList("toppingPriceTop");
 ArrayList<String> toppingDescriptionTop =b.getStringArrayList("toppingDescriptionTop");