android - Convert string to activity name C# -


i using listview in xamarin android display list of restaurants, , when 1 clicked on navigate new activity. activity each named using convention: [restaurantname]activity. i'm trying use intents:

    protected override void onlistitemclick(listview l, view v, int position, long id)     {         string t = items[position] + "activity";         var intentplace = new intent(this, typeof(???));         startactivity(intentplace);     } 

string t gives correct format, wrong type put inside typeof(). however, have no idea put in place of '???', wasn't able use settitle in order create activity name. able point me in right direction?

you need attach full path activities.

var acttype = type.gettype("part of full path" + items[position] + "activity") 

i haven't tested it, should work :)

protected override void onlistitemclick(listview l, view v, int position, long id) {     var acttype = type.gettype("part of full path" + items[position] + "activity")     var intentplace = new intent(this, acttype);     startactivity(intentplace); } 

also usefull if assembly activity has been loaded in current domain


Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -