Saturday, 7 January 2017

Json String to Key Value Pair in C#, Xamarin Android


Json String to Key Value Pair in C#, Xamarin Android

public static Dictionary<string, string> ParseJSONString(string s)
        {
            Regex reg = new Regex("\"(?<Key>[\\w]*)\":\"?(?<Value>([\\s\\w\\d\\.\\\\\\-/:_\\+]+(,[,\\s\\w\\d\\.\\\\\\-/:_\\+]*)?)*)\"?");
            MatchCollection matchCollection  = reg.Matches(s);

            Dictionary<string, string> json = new Dictionary<string, string>();

            foreach (Match kv in matchCollection)
            {
                json.Add(kv.Groups["Key"].Value, kv.Groups["Value"].Value);

            }
            return json;
        }

Spinner-Progress-Bar-Xamarin-Android-C#

Spinner-Progress-Bar-Xamarin-Android-C#


 
var progressDialog = ProgressDialog.Show(this, "Please wait...", "Checking info...", true);
    new Thread(new ThreadStart(delegate
    {
    //Your Code
    RunOnUiThread(() => Toast.MakeText(this, "Toast within progress dialog.", ToastLength.Long).Show());
//Hide Progress Dialog after completion of Task
            RunOnUiThread(() => progressDialog.Hide());
  })).Start();

Change-Status-bar-Color-xamarin-android-C#

Change Status bar Color in Xamarin Android C#.
It is supported for Android 5 or greater.

Window.AddFlags(Android.Views.WindowManagerFlags.DrawsSystemBarBackgrounds);
Window.SetStatusBarColor(Color.ParseColor("#004D40"));