Beispiel #1
0
        public static DependFragment newInstance(string answer)
        {
            DependFragment fragment = new DependFragment();

            fragment.answer = answer;
            return(fragment);
        }
Beispiel #2
0
        public void OnClick(View v)
        {
            //string folder = Android.OS.Environment.ExternalStorageDirectory.AbsolutePath;
            var    dataPath = System.Environment.SpecialFolder.ApplicationData;
            string path     = Path.Combine(System.Environment.GetFolderPath(dataPath).Split("files")[0] + @"files", FileName);

            //File.Create(path + "newFile.png");
            //File.Delete(path);
            if (!File.Exists(path))
            {
                File.Create(path);
            }
            switch (v.Id)
            {
            case Resource.Id.btn_view:
                StringBuilder stringBuilder = new StringBuilder();

                List <string> storage = File.ReadAllLines(path).ToList();
                foreach (var item in storage)
                {
                    string[] temp = item.Split(';');
                    stringBuilder.Append($"{temp[0]} ({temp[1]})\n");
                }

                DependFragment      showFragment = DependFragment.newInstance(stringBuilder.ToString());
                FragmentTransaction transaction  = this.FragmentManager.BeginTransaction();
                transaction.Replace(Resource.Id.container, showFragment);
                etQuestion.Text = "";
                transaction.AddToBackStack(null);
                transaction.Commit();
                break;

            case Resource.Id.btn_continue:

                int         selectedIdColor  = radioGroupColor.CheckedRadioButtonId;
                int         selectedIdPrice  = radioGroupPrice.CheckedRadioButtonId;
                RadioButton radioButtonColor = radioGroupColor.FindViewById <RadioButton>(selectedIdColor);
                RadioButton radioButtonPrice = radioGroupPrice.FindViewById <RadioButton>(selectedIdPrice);
                string      text             = radioButtonColor.Text + " flower, which costs " + radioButtonPrice.Text;
                string      question         = etQuestion.Text.ToString();
                File.AppendAllText(path, $"{question};{text};\n");
                etQuestion.Text = "";
                //etQuestion.ClearFocus();
                Toast.MakeText(v.Context, "Message saved successfully!", ToastLength.Long).Show();
                break;
            }
        }