protected void InitRadioButtons(string[,] aLaunchExtensions, string aUrl, string aResourceID, RadioGroup aRadioGroup) { aRadioGroup.RemoveAllViews(); SortedList <int, RadioButton> _myList = new SortedList <int, RadioButton>(); for (int i = 0; i < aLaunchExtensions.GetLength(0); i++) { string _curS = aLaunchExtensions[i, 0]; string _curParam = aLaunchExtensions[i, 1]; RadioButton _button = new RadioButton(this); _button.Text = string.Format("{0} [{1}]", _curS, _curParam); _button.Tag = i; string _resourceName = aResourceID + _curParam; if (_resourceName == aResourceID) { _resourceName = aResourceID + "nothing"; } ; // int _resourceID = Resources.GetIdentifier(_resourceName, "drawable", this.PackageName); if (_resourceName != "nothing") { try { var _resourceID = (int)typeof(Resource.Drawable).GetField(_resourceName).GetValue(null); if (_resourceID > 0) { Android.Graphics.Drawables.Drawable _d = Resources.GetDrawable(_resourceID); _d.SetBounds(0, 0, 120, 120); _button.SetCompoundDrawables(_d, null, null, null); } ; } catch { }; } ; aRadioGroup.AddView(_button); if ((aUrl.IndexOf(_curParam) >= 0) && (_curParam != "")) { _myList.Add(_curParam.Length, _button); } ; } ; if (_myList.Count > 0) { RadioButton _button = _myList.Values[_myList.Count() - 1]; aRadioGroup.Check(_button.Id); } ; }
private void AddChoices() { TestChoices = JSONHelper.ChoicesList.FindAll(x => (x.QuestionId.Equals(QuestionID))); RadioGroup radioGroupChoices = FindViewById <RadioGroup>(Resource.Id.radioGroup1); radioGroupChoices.ClearCheck(); radioGroupChoices.RemoveAllViews(); foreach (var choice in TestChoices) { RadioButton choiceButton = new RadioButton(this); choiceButton.Text = choice.Body; choiceButton.Id = choice.Id; radioGroupChoices.AddView(choiceButton); } }
private void GenerateQuestion() { answer_is_checked = false; FindViewById <TextView>(Resource.Id.textQuestion).Text = questions[questionIndex].value; radioGroupAnswers.RemoveAllViews(); List <TestHelper.Question.Answer> answers = new List <TestHelper.Question.Answer>(); answers.AddRange(questions[questionIndex].answers); while (answers.Count > 1) { var random = new Random(); int answer_index = random.Next(answers.Count); AddAnswer(answers[answer_index].value, answers[answer_index].is_correct); answers.RemoveAt(answer_index); } AddAnswer(answers[0].value, answers[0].is_correct); FindViewById <Button>(Resource.Id.btnVerify).Visibility = ViewStates.Visible; FindViewById <Button>(Resource.Id.btnNext).Visibility = ViewStates.Gone; }
void StartExercise(Question question, List <Answer> answers, RadioGroup group) { HTML = question.Name; WebView.LoadData(HTML, "text/html", Encoding.UTF8.EncodingName); RadioButtons = new RadioButton[answers.Count]; if (group.ChildCount > 0) { group.RemoveAllViews(); } foreach (var answer in answers) { int index = answers.FindIndex(a => a.ID == answer.ID); RadioButtons[index] = new RadioButton(this) { Text = $"{answer.Name}", Tag = $"{answer.ID}" }; RadioButtons[index].Gravity = GravityFlags.Center; group.AddView(RadioButtons[index]); RadioButtons[index].Click += (o, e) => { AnswerID = answer.ID; }; } }
protected override void OnResume() { base.OnResume(); Console.WriteLine("Resume"); // Find selected data _show = TwitApi.Instance.Shows.FirstOrDefault(s => s.Selected == true); if (_show == null) { Android.Widget.Toast.MakeText(this, "Error finding show", Android.Widget.ToastLength.Short).Show(); Intent i = new Intent(this.ApplicationContext, typeof(MainActivity)); StartActivity(i); return; } _episode = _show.Episodes.FirstOrDefault(e => e.Selected == true); if (_episode == null) { Android.Widget.Toast.MakeText(this, "Error finding episode", Android.Widget.ToastLength.Short).Show(); Intent i = new Intent(this.ApplicationContext, typeof(MainActivity)); StartActivity(i); return; } // Setup UI elements Window.SetTitle(_show.Show.Label + " - " + _episode.Episode.Label); TextView titleTextView = FindViewById <TextView>(Resource.Id.txtvwEpisodeTitle); TextView descriptionTextView = FindViewById <TextView>(Resource.Id.txtvwEpisodeDescription); TextView episodeLengthTextView = FindViewById <TextView>(Resource.Id.txtvwEpisodeLength); titleTextView.Text = _episode.Episode.EpisodeNumber + " - " + _episode.Episode.Label; descriptionTextView.Text = _episode.Episode.Teaser; episodeLengthTextView.Text = _episode.Episode.AudioDetails.RunningTime.ToString() + " - " + _episode.Episode.AiringDate.ToLocalTime().ToString("M/d/yyyy"); _mediaTypeList = FindViewById <RadioGroup>(Resource.Id.mediaTypeList); _mediaTypeList.RemoveAllViews(); RadioButton audioButton = new RadioButton(this.ApplicationContext); RadioButton smallVideoButton = new RadioButton(this.ApplicationContext); RadioButton largeVideoButton = new RadioButton(this.ApplicationContext); RadioButton hdVideoButton = new RadioButton(this.ApplicationContext); audioButton.Text = "Audio"; audioButton.SetPadding(5, 5, 0, 20); smallVideoButton.Text = "Small Video"; smallVideoButton.SetPadding(5, 5, 0, 20); largeVideoButton.Text = "Large Video"; largeVideoButton.SetPadding(5, 5, 0, 20); hdVideoButton.Text = "HD Video"; hdVideoButton.SetPadding(5, 5, 0, 20); _mediaTypeList.AddView(audioButton); _mediaTypeList.AddView(smallVideoButton); _mediaTypeList.AddView(largeVideoButton); _mediaTypeList.AddView(hdVideoButton); // Setup button delegates Button play = FindViewById <Button>(Resource.Id.btnPlayEpisode); play.Click += delegate { // If an episode is already playing in a background, check to make sure the episode we clicked on is different, if it is, stop // the current episode, saving its position, and start playing the new episode. if (PlayingService.ServiceInstance != null) { if (PlayingService.ServiceInstance.Player != null) { if (PlayingService.ServiceInstance.Player.IsPlaying || PlayingService.ServiceInstance.Paused) { if (PlayingService.ServiceInstance.ShowId == _show.Show.Id) { if (PlayingService.ServiceInstance.EpisodeId != _episode.Episode.Id) { PlayingService.ServiceInstance.Stop(); } } else // Show id is not equal, stop because it has to be a different episode even if episode id matches { PlayingService.ServiceInstance.Stop(); } } } } // Start playing episode int radioButtonID = _mediaTypeList.CheckedRadioButtonId; View radioButton = _mediaTypeList.FindViewById(radioButtonID); string videoUrl = ""; int idx = _mediaTypeList.IndexOfChild(radioButton); Type activityToStart = typeof(PlayBackActivity); if (idx > 0) { activityToStart = typeof(VideoViewerActivity); if (idx == 1) { videoUrl = _episode.Episode.SmallVideoDetails.MediaUrl; } else if (idx == 2) { videoUrl = _episode.Episode.LargeVideoDetails.MediaUrl; } else if (idx == 3) { videoUrl = _episode.Episode.HdVideoDetails.MediaUrl; } } Intent i = new Intent(this.ApplicationContext, activityToStart); if (videoUrl != "") { i.PutExtra("VideoUrl", videoUrl); } StartActivity(i); }; }