Pass 2D array to another Activity

后端 未结 5 1979
猫巷女王i
猫巷女王i 2020-11-30 12:43

how do i pass 2 denominational array object as a parameter to another activity

how to get two dimensional array string value in another activity

   S         


        
5条回答
  •  遥遥无期
    2020-11-30 13:24

    You can use putSerializable. Arrays are serializable.

    To store:

    bundle.putSerializable("list", selected_list); // Here bundle is Bundle object.

    To access:

    String[][] passedString_list = (String[][]) bundle.getSerializable("list");
    

    Example

    Intent mIntent = new Intent(this, Example.class);
    Bundle mBundle = new Bundle();
    mBundle.putSerializable("list", selected_list);
    mIntent.putExtras(mBundle);
    

提交回复
热议问题