Android:Passing a hash map between Activities

后端 未结 5 1026
我在风中等你
我在风中等你 2020-11-27 03:59

I have a map between string and a class object. I populate this map in Activity1 and i would like to pass it to activity2.

public class NEW extends Activity         


        
5条回答
  •  抹茶落季
    2020-11-27 04:53

    Create a new java file which will be global for whole application.

    Step1:

    public class GlobalClass extends android.app.Application 
    {
     public static Map data_map = new Map();
    }
    

    Step2:

    After doing that, Register this "GlobalClass" in AndroidManifest.xml

    
    
    

    Step3:

    now you can use this Map anywhere in your application.

    @Override
    protected void onCreate(Bundle icicle)
    {
     GlobalClass global = (GlobalClass)getApplication();
     Map my_map_data = global.data_map;
    }
    

    These steps maybe helpful for you...

提交回复
热议问题