c# - Xamarin android pass multiple variables between activities -



c# - Xamarin android pass multiple variables between activities -

i have list gets info form (where can fill in name , amount), when want send 1 variable works.

i want following:

//activity 1 var sec = new intent(this, typeof(activity2)); second.putextra("name", name); second.putextra("amount", amount); startactivity(second); //activity 2 string name = intent.getstringextra("name") ?? "no data"; string amount= intent.getstringextra("amount") ?? "no data";

but when info on other activity, amount , name have same value

if items same object/class.. you can create class has these properties , utilize json serialize/deserialize between activities example:

//activity 1 var objectstring = newtonsoft.json.jsonconvert.serializeobject(yourclass); var activity = new intent(this, typeof(activityname)); activity.putextra("yourobjectname", objectstring ); startactivity(activity); //activity 2 var _objectstring = intent.getstringextra("yourobjectname") ?? string.empty; if (!string.isnullorempty(_objectstring)) { var instanceofyouclass = jsonconvert.deserializeobject<yourclass>(_objectstring); }

c# android xamarin

Comments

Popular posts from this blog

assembly - What is the addressing mode for ld, add, and rjmp instructions? -

vowpalwabbit - Interpreting Vowpal Wabbit results: Why are some lines appended by "h"? -

Is there a way to convert an HTML page styled with Bootstrap CSS into email-compatible html? -