public override Dialog OnCreateDialog(Bundle savedInstanceState) { LinearLayout container = new LinearLayout(this.Activity); LinearLayout.LayoutParams layoutparameters = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent); layoutparameters.SetMargins(15, 20, 15, 5); Individual = new RadioButton(this.Activity) { Text = "Individual Game", LayoutParameters = layoutparameters }; Tournament = new RadioButton(this.Activity) { Text = "Tournament", LayoutParameters = layoutparameters }; RadioGroup rg = new RadioGroup(this.Activity) { LayoutParameters = layoutparameters }; rg.AddView(Individual); rg.AddView(Tournament); rg.CheckedChange += Rg_CheckedChange; container.AddView(rg); AlertDialog.Builder inputDialog = new AlertDialog.Builder(this.Activity); inputDialog.SetTitle(_title); inputDialog.SetView(container); inputDialog.SetNegativeButton("Cancel", (senderAlert, args) => { Toast.MakeText(this.Activity, "Canceled.", ToastLength.Short).Show(); }); return(inputDialog.Show()); }
public override View GetSampleContent(Context con) { LinearLayout linear = new LinearLayout(con); linear.SetBackgroundColor(Android.Graphics.Color.White); linear.Orientation = Orientation.Vertical; linear.SetPadding(10, 10, 10, 10); TextView text2 = new TextView(con); text2.TextSize = 17; text2.TextAlignment = TextAlignment.Center; text2.Text = "This sample demonstrates how to accept or reject the tracked changes in the Word document using Essential DocIO."; text2.SetTextColor(Android.Graphics.Color.ParseColor("#262626")); text2.SetPadding(5, 5, 5, 5); linear.AddView(text2); TextView space1 = new TextView(con); space1.TextSize = 10; linear.AddView(space1); m_context = con; LinearLayout radioLinearLayoutVertical = new LinearLayout(con); radioLinearLayoutVertical.Orientation = Orientation.Vertical; radioGroup = new RadioGroup(con); radioGroup.TextAlignment = TextAlignment.Center; radioGroup.Orientation = Orientation.Vertical; acceptAll = new RadioButton(con); acceptAll.Text = "Accepts all the tracked changes in the Word document"; radioGroup.AddView(acceptAll); rejectAll = new RadioButton(con); rejectAll.Text = "Rejects all the tracked changes in the Word document"; radioGroup.AddView(rejectAll); radioGroup.Check(1); radioLinearLayoutVertical.AddView(radioGroup); linear.AddView(radioLinearLayoutVertical); acceptAll.Checked = true; TextView space2 = new TextView(con); space2.TextSize = 10; linear.AddView(space2); Button viewButton = new Button(con); viewButton.Text = "View Template"; viewButton.Click += OnButtonClicked1; linear.AddView(viewButton); TextView space3 = new TextView(con); space3.TextSize = 10; linear.AddView(space3); Button generateButton = new Button(con); generateButton.Text = "Generate"; generateButton.Click += OnButtonClicked2; linear.AddView(generateButton); return(linear); }
public override View GetSampleContent(Context con) { LinearLayout linear = new LinearLayout(con); linear.SetBackgroundColor(Android.Graphics.Color.White); linear.Orientation = Orientation.Vertical; linear.SetPadding(10, 10, 10, 10); TextView text2 = new TextView(con); text2.TextSize = 17; text2.TextAlignment = TextAlignment.Center; text2.Text = "This sample demonstrates how to encrypt and decrypt the Word document using Essential DocIO."; text2.SetTextColor(Android.Graphics.Color.ParseColor("#262626")); text2.SetPadding(5, 5, 5, 5); linear.AddView(text2); TextView space1 = new TextView(con); space1.TextSize = 10; linear.AddView(space1); m_context = con; LinearLayout radioLinearLayoutVertical = new LinearLayout(con); radioLinearLayoutVertical.Orientation = Orientation.Vertical; radioGroup = new RadioGroup(con); radioGroup.TextAlignment = TextAlignment.Center; radioGroup.Orientation = Orientation.Vertical; encryptDocument = new RadioButton(con); encryptDocument.Text = "Encrypt Document"; radioGroup.AddView(encryptDocument); decryptDocument = new RadioButton(con); decryptDocument.Text = "Decrypt Document"; radioGroup.AddView(decryptDocument); radioGroup.Check(1); radioLinearLayoutVertical.AddView(radioGroup); linear.AddView(radioLinearLayoutVertical); encryptDocument.Checked = true; TextView space2 = new TextView(con); space2.TextSize = 10; linear.AddView(space2); Button generateButton = new Button(con); generateButton.Text = "Generate"; generateButton.Click += OnButtonClicked; linear.AddView(generateButton); return(linear); }
protected override void OnBindDialogView(View view) { base.OnBindDialogView(view); var currentValue = GetPersistedInt(SettingsScreen.DefaultRadiusValue); if (BuildVersionCodes.Honeycomb > Build.VERSION.SdkInt) { _radioGroup = (RadioGroup)view; foreach (var distance in Constants.AlarmRadiusValues) { var radioButton = new RadioButton(Context); radioButton.SetText(string.Format(Context.GetString(Resource.String.settings_default_radius_sum), distance), TextView.BufferType.Normal); radioButton.Checked = distance == currentValue; radioButton.Id = distance; _radioGroup.AddView(radioButton); } } else { _numberPicker = (NumberPicker)view; SetNumberPickerTextColor(_numberPicker, Context.Resources.GetColor(Resource.Color.dark)); _numberPicker.DescendantFocusability = DescendantFocusability.BlockDescendants; _numberPicker.SetDisplayedValues(Constants.AlarmRadiusValues.Select(v => v.ToString()).ToArray()); _numberPicker.MinValue = 0; _numberPicker.MaxValue = Constants.AlarmRadiusValues.Count() - 1; _numberPicker.WrapSelectorWheel = false; _numberPicker.Value = Constants.AlarmRadiusValues.IndexOf(currentValue); } }
private void InitComponents() { this.Title = "Live Survey"; var txtQuestion = FindViewById <TextView>(Resource.Id.txtLiveQuestion); txtQuestion.Text = VM.CurrentQuestion.QuestionText; if (VM.CurrentQuestion.IsMultiSelect) { foreach (var opt in VM.CurrentQuestion.Options) { var button = new CheckBox(this); button.Text = opt.OptionText; button.Checked = opt.IsSelected; button.Id = opt.Id; button.CheckedChange += button_CheckedChange; layout.AddView(button); } } else { radioGroup = new RadioGroup(this); foreach (var opt in VM.CurrentQuestion.Options) { var button = new RadioButton(this); button.Text = opt.OptionText; button.Checked = opt.IsSelected; button.Id = opt.Id; radioGroup.AddView(button); } layout.AddView(radioGroup); radioGroup.CheckedChange += radioGroup_CheckedChange; } }
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 AddAnswer(string value, bool is_correct) { RadioButton radio = new RadioButton(this) { Text = value, Tag = is_correct }; radio.Click += Radio_Click; radioGroupAnswers.AddView(radio); }
private void _DisplayPairedDevices() { RadioButton rb; foreach (string name in _bluetooth.PairedDeviceNames) { rb = new RadioButton(this); rb.Text = name; _rButtons.Add(rb); _rbDevices.AddView(rb); } }
public void createRadioButtonsAndAddtoRadioGroup(String checkedValue, RadioGroup radioGroup) { String[] categoryOptionsArray = Resources.GetStringArray(Resource.Array.BoardGamesCategorys); for (int index = 0; index < categoryOptionsArray.Length; index++) { RadioButton radioButton = new RadioButton(Application.Context); radioButton.Text = categoryOptionsArray[index]; radioButton.Id = index; if (radioButton.Text.Equals(checkedValue)) { radioButton.Checked = true; } radioGroup.AddView(radioButton); } }
public async Task <int?> ChooseSingleAsync(string message, string[] options, int?chosenItem = null, string title = null, string okButton = "OK", string cancelButton = "Cancel", CancellationToken ct = default(CancellationToken)) { var context = this.GetContextOrThrow(); var radioButtons = options .Select((option, i) => { var checkBox = new RadioButton(context) { LayoutParameters = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent) { Gravity = GravityFlags.CenterVertical }, Id = i + 1, Text = option, Gravity = GravityFlags.Center, }; checkBox.SetTextColor(Color.White); return(checkBox); }) .ToArray(); var radioGroup = new RadioGroup(context) { LayoutParameters = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent), Orientation = Orientation.Vertical }; foreach (var optionLayout in radioButtons) { radioGroup.AddView(optionLayout); } var scrollView = new ScrollView(context) { LayoutParameters = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent), }; scrollView.AddView(radioGroup); return(await this._showDialogService.ShowAsync(message, title, scrollView, okButton, cancelButton, null, ct).ConfigureAwait(true) == ConfirmThreeButtonsResponse.Positive ? (radioGroup.CheckedRadioButtonId > 0 ? radioGroup.CheckedRadioButtonId - 1 : (int?)null) : null); }
private void SetCurrentATask() { var curTask = test.GetATask(currentTaskNum); if (curTask != null) { taskNameLabel.Text = "A" + (currentTaskNum + 1); taskLabel.Text = curTask.Desc; if (!String.IsNullOrEmpty(curTask.ImageLink)) { taskImage.Visibility = ViewStates.Visible; using (Stream ims = Assets.Open(curTask.ImageLink)) { Drawable d = Drawable.CreateFromStream(ims, null); taskImage.SetImageDrawable(d); } } RadioGroup variantGroup = new RadioGroup(this); variantGroup.CheckedChange += (object sender, RadioGroup.CheckedChangeEventArgs e) => { if (e.CheckedId != -1) { for (int i = 0; i < variantGroup.ChildCount; i++) { RadioButton child = (RadioButton)variantGroup.GetChildAt(i); if (child.Id == e.CheckedId) { aAnswers [currentTaskNum] = i; } } } }; variantGroup.Orientation = Orientation.Vertical; int index = 0; foreach (var variant in curTask.Variants) { RadioButton variantRadio = new RadioButton(this); variantRadio.Text = variant; variantGroup.AddView(variantRadio); if ((aAnswers[currentTaskNum] != NoSelectedAnswers) && (index == aAnswers[currentTaskNum])) { variantGroup.Check(variantRadio.Id); } index++; } variantsLayout.AddView(variantGroup); } }
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); } }
public async Task GetAllCandidates() { var request = new RestRequest("voting/getallcandidates", Method.GET); var voteService = new VoteService(); var result = await voteService.ExecuteAsync <List <Candidates> >(request); candidate = result; var postion = result.Select(item => item.Position).Distinct().ToList(); foreach (var pos in postion) { var button = new Button(this) { Text = pos, LayoutParameters = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent), Id = 1 + 1 }; layout.AddView(button); var rdg = new RadioGroup(this) { LayoutParameters = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent), Id = 1 + 1 }; foreach (var candidate in result) { if (pos == candidate.Position) { var radioButton = new RadioButton(this); radioButton.Id = candidate.StudentNumber; radioButton.Text = candidate.FullName; rdg.AddView(radioButton); } } layout.AddView(rdg); } var btnFinish = new Button(this); btnFinish.Text = "Finish"; btnFinish.LayoutParameters = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent); btnFinish.Click += BtnFinish_Click; layout.AddView(btnFinish); }
/// <summary> /// Programmatically generates RadioButtons and adds them to the given RadioGroup with a given list as Dictionary. /// </summary> /// <param name="context">Context</param> /// <param name="radioGroup">RadioGroup</param> /// <param name="list">List</param> /// <param name="defaultIndex">default index</param> public static void PopulateRadioGroupWithList(Activity context, RadioGroup radioGroup, Dictionary <String, EnergyScanView.ScanMode> list, int defaultIndex) { //if list is empty, remove the radio group if (list == null) { context.FindViewById <RelativeLayout>(Resource.Id.root).RemoveView(radioGroup); return; } foreach (var pair in list) { var radioButton = new RadioButton(context) { Text = pair.Key }; radioGroup.AddView(radioButton, radioGroup.ChildCount, radioGroup.LayoutParameters); } radioGroup.Check(radioGroup.GetChildAt(defaultIndex).Id); }
private void ShowRadioButtonDialog() { dialog = new Dialog(this); dialog.SetContentView(Resource.Layout.radiobutton_dialog); dialog.SetCancelable(true); RadioGroup rg = (RadioGroup)dialog.FindViewById(Resource.Id.radio_group); foreach (var lang in Globals.LanguageMap) { RadioButton rb = new RadioButton(this); rb.SetPadding(0, 20, 0, 20); if (lang.Key == Globals.Language) { rb.Checked = true; } rb.Click += Rb_Click; rb.SetText(lang.Key, TextView.BufferType.Normal); rg.AddView(rb); } dialog.Show(); }
public override bool OnOptionsItemSelected(IMenuItem item) { int id = item.ItemId; if (id == Resource.Id.action_settings) { StartActivity(typeof(SignInActivity)); } else if (id == Resource.Id.action_changeView) { Dialog dialog = new Dialog(this); dialog.SetContentView(Resource.Layout.custom_dialoge); Dictionary <int, String> stringList = new Dictionary <int, string>(); // here is list stringList.Add(GoogleMap.MapTypeNone, "None"); stringList.Add(GoogleMap.MapTypeNormal, "Normal"); stringList.Add(GoogleMap.MapTypeSatellite, "Satellite"); stringList.Add(GoogleMap.MapTypeTerrain, "Terrain"); stringList.Add(GoogleMap.MapTypeHybrid, "Hybrid"); RadioGroup rg = (RadioGroup)dialog.FindViewById(Resource.Id.radio_group); foreach (var type in stringList) { RadioButton rb1 = new RadioButton(this); // dynamically creating RadioButton and adding to RadioGroup. rb1.Text = type.Value; rg.AddView(rb1); rb1.Click += delegate { dialog.Hide(); onViewSelected(type.Key); }; } dialog.SetTitle("Select View"); //TODO: Divyesh View title not working dialog.Show(); dialog.Window.SetLayout(700, 600); } return(base.OnOptionsItemSelected(item)); }
public static RadioButton CreateRadioButton(RadioGroup radioGroup, int page, int id, string text, bool flag) { RadioButton radioButton = new RadioButton(radioGroup.Context); radioButton.Id = id; radioButton.Text = text; radioButton.TextSize = 18; radioButton.Checked = flag; //radioButton.SetOnClickListener(new View.IOnClickListener() { }); radioButton.Click += (sender, e) => { View v = (View)sender; QuestionarioManager.GetInstance().UpdateFirstRespostaSelected(page, v.Id); }; if (flag) { radioButton.Checked = true; } radioGroup.AddView(radioButton, -2, -2); return(radioButton); }
private void ShowEmailsAlert(List <string> emails) { LayoutInflater inflater = ((Activity)Context).LayoutInflater; View view = inflater.Inflate(Resource.Layout.CustomAlert, null); ViewGroup viewGroup = view.FindViewById <ViewGroup>(Resource.Id.ll_alert); viewGroup.SetPadding(40, 20, 10, 20); RadioGroup group = new RadioGroup(Context); for (int i = 0; i < emails.Count; i++) { RadioButton radio = new RadioButton(Context) { Text = emails[i], TextSize = 16, Id = i }; if (i == 0) { radio.Checked = true; } group.AddView(radio); } viewGroup.AddView(group); AlertDialog.Builder builder = new AlertDialog.Builder(Context); builder.SetTitle(Presenter.GetShowEmailsAlertTitleLocale()) .SetView(view) .SetCancelable(false) .SetNegativeButton(Presenter.GetCancelLocale(), (o, e) => { }) .SetPositiveButton(Presenter.GetOkLocale(), (o, e) => { _holder.EmailEditText.Text = emails[group.CheckedRadioButtonId]; }) .Show(); }
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; }; } }
public override View GetSampleContent(Context con) { LinearLayout linear = new LinearLayout(con); linear.SetBackgroundColor(Color.White); linear.Orientation = Orientation.Vertical; linear.SetPadding(10, 10, 10, 10); TextView text1 = new TextView(con); text1.TextSize = 17; text1.TextAlignment = TextAlignment.Center; text1.SetTextColor(Color.ParseColor("#262626")); text1.Text = "This sample demonstrates how to create a Word document with mathematical equations using Essential DocIO."; text1.SetPadding(5, 10, 10, 5); linear.AddView(text1); TextView space1 = new TextView(con); space1.TextSize = 10; linear.AddView(space1); m_context = con; LinearLayout radioLinearLayout = new LinearLayout(con); radioLinearLayout.Orientation = Orientation.Horizontal; TextView imageType = new TextView(con); imageType.Text = "Save As : "; imageType.TextSize = 19; radioLinearLayout.AddView(imageType); radioGroup = new RadioGroup(con); radioGroup.TextAlignment = TextAlignment.Center; radioGroup.Orientation = Orientation.Horizontal; docxButton = new RadioButton(con); docxButton.Text = "DOCX"; radioGroup.AddView(docxButton); pdfButton = new RadioButton(con); pdfButton.Text = "PDF"; radioGroup.AddView(pdfButton); radioGroup.Check(1); radioLinearLayout.AddView(radioGroup); linear.AddView(radioLinearLayout); docxButton.Checked = true; TextView space2 = new TextView(con); space2.TextSize = 10; linear.AddView(space2); Button button1 = new Button(con); button1.Text = "Generate"; button1.Click += OnButtonClicked; linear.AddView(button1); return(linear); }
public override View GetSampleContent(Context con) { LinearLayout linear = new LinearLayout(con); linear.SetBackgroundColor(Color.White); linear.Orientation = Orientation.Vertical; linear.SetPadding(10, 10, 10, 10); TextView text2 = new TextView(con); text2.TextSize = 17; text2.TextAlignment = TextAlignment.Center; text2.Text = "This sample illustrates the conversion of a simple Excel document to HTML file."; text2.SetTextColor(Color.ParseColor("#262626")); text2.SetPadding(5, 5, 5, 5); linear.AddView(text2); TextView space1 = new TextView(con); space1.TextSize = 10; linear.AddView(space1); m_context = con; LinearLayout radioLinearLayout = new LinearLayout(con); radioLinearLayout.Orientation = Orientation.Horizontal; TextView imageType = new TextView(con); imageType.Text = "Convert : "; imageType.TextSize = 19; radioLinearLayout.AddView(imageType); radioGroup = new RadioGroup(con); radioGroup.TextAlignment = TextAlignment.Center; radioGroup.Orientation = Orientation.Horizontal; workbookButton = new RadioButton(con); workbookButton.Text = "Workbook"; radioGroup.AddView(workbookButton); radioGroup.Selected = true; worksheetButton = new RadioButton(con); worksheetButton.Text = "Worksheet"; radioGroup.AddView(worksheetButton); radioLinearLayout.AddView(radioGroup); linear.AddView(radioLinearLayout); workbookButton.Checked = true; TextView space2 = new TextView(con); space2.TextSize = 10; linear.AddView(space2); Button templateButton = new Button(con); templateButton.Text = "Input Template"; templateButton.Click += OnButtonClicked; linear.AddView(templateButton); Button convertButton = new Button(con); convertButton.Text = "Convert"; convertButton.Click += OnConvertButtonClicked; linear.AddView(convertButton); return(linear); }
private void showUIControlBasedOnSelection(string intentData) { Console.WriteLine("on Switch case"); LinearLayout linearLayoutObject = (LinearLayout)FindViewById(Resource.Id.linearLayout); switch (intentData) { case UI_CONTROLS_IN_ANDROID.textView: TextView textView = new TextView(this); textView.Text = "Its a sample Text View"; textView.SetTextColor(Android.Graphics.Color.Red); textView.SetBackgroundColor(Android.Graphics.Color.White); linearLayoutObject.AddView(textView); break; case UI_CONTROLS_IN_ANDROID.button: Button myButton = new Button(this); myButton.Text = "Sample Button"; linearLayoutObject.AddView(myButton); break; case UI_CONTROLS_IN_ANDROID.autocompleteTextview: AutoCompleteTextView autocompleteTextView = new AutoCompleteTextView(this); autocompleteTextView.Text = "Its a sample AutoTextView"; autocompleteTextView.SetTextColor(Android.Graphics.Color.Red); autocompleteTextView.SetBackgroundColor(Android.Graphics.Color.White); linearLayoutObject.AddView(autocompleteTextView); break; case UI_CONTROLS_IN_ANDROID.imageButton: ImageButton imageButton = new ImageButton(this); imageButton.SetImageResource(Resource.Drawable.mac); linearLayoutObject.AddView(imageButton); break; case UI_CONTROLS_IN_ANDROID.checkbox: CheckBox checkBox = new CheckBox(this); checkBox.Click += (o, e) => { if (checkBox.Checked) { Toast.MakeText(this, "Selected", ToastLength.Short).Show(); } else { Toast.MakeText(this, "Not selected", ToastLength.Short).Show(); } }; linearLayoutObject.AddView(checkBox); break; case UI_CONTROLS_IN_ANDROID.toggleButton: ToggleButton toggleButton = new ToggleButton(this); toggleButton.Click += (o, e) => { // Perform action on clicks if (toggleButton.Checked) { Toast.MakeText(this, "On", ToastLength.Short).Show(); } else { Toast.MakeText(this, "Off", ToastLength.Short).Show(); } }; linearLayoutObject.AddView(toggleButton); break; case UI_CONTROLS_IN_ANDROID.radioButton: RadioButton radioButton = new RadioButton(this); radioButton.Text = "Check the radio button"; radioButton.Click += (o, e) => { Toast.MakeText(this, radioButton.Text, ToastLength.Short).Show(); }; linearLayoutObject.AddView(radioButton); break; case UI_CONTROLS_IN_ANDROID.radioGroup: RadioGroup radioGroup = new RadioGroup(this); RadioButton maleRadioButton = new RadioButton(this); maleRadioButton.Text = "Male"; maleRadioButton.Click += RadioButtonClick; radioGroup.AddView(maleRadioButton); RadioButton femaleRadioButton = new RadioButton(this); femaleRadioButton.Text = "Female"; femaleRadioButton.Click += RadioButtonClick; radioGroup.AddView(femaleRadioButton); RadioButton otherRadioButton = new RadioButton(this); otherRadioButton.Text = "Other"; otherRadioButton.Click += RadioButtonClick; radioGroup.AddView(otherRadioButton); linearLayoutObject.AddView(radioGroup); break; case UI_CONTROLS_IN_ANDROID.progressBar: ProgressBar progressBar = new ProgressBar(this); progressBar.Max = 100; progressBar.Progress = 30; linearLayoutObject.AddView(progressBar); break; case UI_CONTROLS_IN_ANDROID.spinner: Spinner spinner = new Spinner(this); spinner.ItemSelected += this.SpinnerItemSelected; string[] data = { "Spinner Item 1", "Spinner Item 2", "Spinner Item 3", "Spinner Item 4", "Spinner Item 5" }; ArrayAdapter spinnerArrayAdapter = new ArrayAdapter(this, Android.Resource.Layout.SimpleSpinnerItem, data); spinner.Adapter = spinnerArrayAdapter; linearLayoutObject.AddView(spinner); break; case UI_CONTROLS_IN_ANDROID.timePicker: TimePicker timePicker = new TimePicker(this); timePicker.TimeChanged += (o, e) => { this.onTimeChanged(timePicker, timePicker.Hour, timePicker.Minute); }; linearLayoutObject.AddView(timePicker); break; case UI_CONTROLS_IN_ANDROID.datePicker: DatePicker datePicker = new DatePicker(this); datePicker.DateChanged += (o, e) => { Toast.MakeText(this, datePicker.DayOfMonth + " : " + datePicker.Month + " : " + datePicker.Year, ToastLength.Short).Show(); }; linearLayoutObject.AddView(datePicker); break; default: break; } }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { var view = inflater.Inflate(Resource.Layout.fragment_dictlist, container, false); //EditText etDictName = view.FindViewById<EditText>(Resource.Id.etDictListDictName); TextView tvHint = view.FindViewById <TextView>(Resource.Id.tvHint); Button btDelete = view.FindViewById <Button>(Resource.Id.btDelete); Button btOpenDict = view.FindViewById <Button>(Resource.Id.btOpenDict); Button btRefresh = view.FindViewById <Button>(Resource.Id.btRefresh); Button btRecreate = view.FindViewById <Button>(Resource.Id.btRecreate); //btDelete.Enabled = false; RadioGroup rgDictList = view.FindViewById <RadioGroup>(Resource.Id.rgDictList); int iSelectedID = 0; DatabaseManager dm = new DatabaseManager(); string sDictName = dm.GetDefaultValueByKey("DictName"); List <string> dictList = dm.GetDictNameList(); for (int i = 0; i < dictList.Count; i++) { RadioButton rbNew = new RadioButton(view.Context); rbNew.Id = View.GenerateViewId();//start from 1. //set attributes "wrap_content" dynamically.(but it has been set default. //LinearLayout.LayoutParams parmsWrapContent = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WrapContent, LinearLayout.LayoutParams.WrapContent); //rbNew.LayoutParameters = parmsWrapContent; rbNew.Text = dictList[i]; if (rbNew.Text.Equals(sDictName)) { iSelectedID = rbNew.Id; } rgDictList.AddView(rbNew); } rgDictList.CheckedChange += (sender, e) => { btDelete.Enabled = true; iSelectedID = e.CheckedId; RadioButton rbNew = view.FindViewById <RadioButton>(e.CheckedId); if (rbNew is null) { return; } sDictName = rbNew.Text; dm.SetDefaultValue("DictName", sDictName); tvHint.Text = "Dictionary: " + sDictName + " is selected! " + dm.GetTotalWordsNumberByDictName(sDictName) + " words."; }; //must be executed after listener "CheckedChange" definited. rgDictList.Check(iSelectedID); /* * for (int i = 0; i < rgDictList.ChildCount; i++) * { * RadioButton rbNew = view.FindViewById<RadioButton>(rgDictList.GetChildAt(i).Id); * if(rbNew.Text.Equals(sDictName)) * { * iSelectedID = rgDictList.GetChildAt(i).Id; * rgDictList.Check(iSelectedID); * break; * } * } */ btOpenDict.Click += delegate { Fragment fragment = new OpenDict(); FragmentManager.BeginTransaction().Replace(Resource.Id.flContent, fragment).Commit(); }; //remove words which is in "Trash" or "PassDict" from selected dictionary. btRefresh.Click += delegate { if (sDictName.Equals("Trash") || sDictName.Equals("PassDict")) { return; } List <string> lSelectedDict = dm.GetWordListByDictName(sDictName); List <string> lTrash = dm.GetWordListByDictName("Trash"); List <string> lPassDict = dm.GetWordListByDictName("PassDict"); foreach (string sWord in lSelectedDict) { if (lTrash.Contains(sWord)) { dm.RemoveWordFromDict(sDictName, sWord); } if (lPassDict.Contains(sWord)) { dm.RemoveWordFromDict(sDictName, sWord); } } tvHint.Text = "Dictionary: " + sDictName + " is refreshed! " + dm.GetTotalWordsNumberByDictName(sDictName) + " words."; }; btRecreate.Click += delegate { if (sDictName.Equals("Trash") || sDictName.Equals("PassDict") || sDictName.Equals("NewWord")) { return; } DictDataModel ddm = dm.GetDictFromDBByName(sDictName); if (ddm is null) { ddm = new DictDataModel(); ddm.sDictName = sDictName; } ddm.UpdateDictWord(); dm.StoreDictToDB(ddm); tvHint.Text = "Dictionary: " + sDictName + " is recreated! " + dm.GetTotalWordsNumberByDictName(sDictName) + " words."; }; //delete dictionary. name can be set manually btDelete.Click += delegate { for (int i = 0; i < rgDictList.ChildCount; i++) { if (rgDictList.GetChildAt(i).Id == iSelectedID) { if (!sDictName.Equals("")) { dm.RemoveDictByName(sDictName); dm.SetDefaultValue("DictName", ""); } rgDictList.RemoveViewAt(i); break; } } btDelete.Enabled = false; dm.RemoveDictByName(sDictName); DictDataModel ddm = dm.GetDictFromDBByName(sDictName); }; return(view); //return base.OnCreateView(inflater, container, savedInstanceState); }
protected override View OnCreateDialogView() { LayoutInflater inflator = LayoutInflater.FromContext(this.Context); View dialog = inflator.Inflate(Resource.Layout.opencl_preference, null); _openCLRadioGroup = dialog.FindViewById <RadioGroup>(Resource.Id.opencl_preference_radio_group); AppPreference preference = new AppPreference(); RadioButton checkedButton = null; RadioButton cpuButton = new RadioButton(this.Context); cpuButton.Text = "CPU (no OpenCL)"; _openCLRadioGroup.AddView(cpuButton); //int selectedIdx = -1; if (preference.UseOpenCL == false) { checkedButton = cpuButton; } cpuButton.Click += (sender, args) => { preference.UseOpenCL = false; //Toast.MakeText(this.Context, "cpu clicked", ToastLength.Short).Show(); }; String selectedDeviceName = preference.OpenClDeviceName; if (selectedDeviceName == null && CvInvoke.HaveOpenCL && preference.UseOpenCL) { selectedDeviceName = Emgu.CV.Ocl.Device.Default.Name; } if (CvInvoke.HaveOpenCL) { using (VectorOfOclPlatformInfo oclPlatformInfos = Emgu.CV.Ocl.OclInvoke.GetPlatformsInfo()) { if (oclPlatformInfos.Size > 0) { for (int i = 0; i < oclPlatformInfos.Size; i++) { Emgu.CV.Ocl.PlatformInfo platformInfo = oclPlatformInfos[i]; for (int j = 0; j < platformInfo.DeviceNumber; j++) { Emgu.CV.Ocl.Device device = platformInfo.GetDevice(j); RadioButton deviceButton = new RadioButton(this.Context); deviceButton.Text = "OpenCL: " + device.Name; if (preference.UseOpenCL == true && device.Name.Equals(selectedDeviceName)) { checkedButton = deviceButton; } _openCLRadioGroup.AddView(deviceButton); //counter++; deviceButton.Click += (sender, args) => { preference.UseOpenCL = true; preference.OpenClDeviceName = device.Name; //Toast.MakeText(this.Context, device.Name + " clicked", ToastLength.Short).Show(); }; } } } } } if (checkedButton != null) { _openCLRadioGroup.Check(checkedButton.Id); } //_openCLRadioGroup.in /* * _openCLToggleButton.Checked = preference.UseOpenCL; * * _openCLToggleButton.CheckedChange += (sender, args) => * { * bool isChecked = args.IsChecked; * * if (isChecked && !CvInvoke.HaveOpenCL) * { * _openCLToggleButton.Checked = false; * Toast.MakeText(Context, "No OpenCL compatible device found.", ToastLength.Long).Show(); * isChecked = false; * } * * preference.UseOpenCL = isChecked; * }; */ return(dialog); }
void Initialize(Dictionary <string, QuestionGroup> questionGroups, string questionGroupName, int questionNumber, int savedAnswer) { QuestionGroups = questionGroups; QuestionGroupName = questionGroupName; QuestionNumber = questionNumber; BgColor = new Color(int.Parse(QuestionGroups[QuestionGroupName].Background, NumberStyles.AllowHexSpecifier | NumberStyles.HexNumber)); SetBackgroundColor(BgColor); rbGroup = (RadioGroup)LayoutInflater.From(Context).Inflate(Resource.Layout.questionGroup, this, false); var lpg = new LayoutParams(LayoutParams.WrapContent, LayoutParams.WrapContent); lpg.AddRule(LayoutRules.CenterInParent); AddView(rbGroup, lpg); var question = questionGroups[questionGroupName].Questions[questionNumber]; var txtQuestionNumber = new TextView(Context) { Text = $"{QuestionNumber+1} / {QuestionGroups[QuestionGroupName].Questions.Count}", TextSize = 16, Id = 18 }; txtQuestionNumber.SetPaddingRelative(0, 20, 0, 20); txtQuestionNumber.SetTextColor(Color.Black); var lpqn = new LayoutParams(LayoutParams.WrapContent, LayoutParams.WrapContent); lpqn.AddRule(LayoutRules.AlignParentTop); lpqn.AddRule(LayoutRules.CenterHorizontal); AddView(txtQuestionNumber, lpqn); var txtQuestion = new TextView(Context) { Text = question.Text, TextSize = 20 }; txtQuestion.SetTextSize(ComplexUnitType.Dip, 26); txtQuestion.SetTextColor(Color.Black); txtQuestion.SetTypeface(Typeface.DefaultBold, TypefaceStyle.Bold); var lpt = new LayoutParams(LayoutParams.WrapContent, LayoutParams.WrapContent); lpt.AddRule(LayoutRules.CenterHorizontal); lpt.AddRule(LayoutRules.Below, 18); AddView(txtQuestion, lpt); var answers = question.Answers; for (var i = 0; i < answers.Count; i++) { var rbEntry = (RadioButton)LayoutInflater.From(Context).Inflate(Resource.Layout.questionEntry, this, false); rbEntry.Checked = false; rbEntry.Id = i; rbEntry.Text = $"{answers[i].Text}"; rbEntry.CheckedChange += RbEntry_CheckedChange; rbGroup.AddView(rbEntry); if (i == savedAnswer) { rbEntry.Checked = true; } } var btn = new Button(Context) { Text = Resources.GetString(Resource.String.SubmitQuestion) + " ", Background = null, Visibility = QuestionNumber < QuestionGroups[QuestionGroupName].Questions.Count - 1? ViewStates.Gone : ViewStates.Visible }; btn.SetTextSize(ComplexUnitType.Dip, 20); btn.SetCompoundDrawablesWithIntrinsicBounds(0, 0, Resource.Drawable.Submit, 0); btn.Touch += Btn_Touch; var lpb = new LayoutParams(LayoutParams.WrapContent, LayoutParams.WrapContent); lpb.AddRule(LayoutRules.AlignParentRight); lpb.AddRule(LayoutRules.CenterVertical); AddView(btn, lpb); var buttonBar = new RelativeLayout(Context); buttonBar.SetBackgroundColor(Color.White); var buttonBarLP = new LayoutParams(LayoutParams.MatchParent, 110); buttonBarLP.AddRule(LayoutRules.AlignParentBottom); AddView(buttonBar, buttonBarLP); var btnPrev = new Button(Context) { Text = " " + Resources.GetString(Resource.String.PrevQuestion), TextSize = 14, Background = null, Visibility = QuestionNumber == 0 ? ViewStates.Gone : ViewStates.Visible }; btnPrev.SetTextSize(ComplexUnitType.Dip, 20); btnPrev.Click += BtnPrev_Click; var prevArrow = Resources.GetDrawable(Resource.Drawable.Prev); prevArrow.Bounds = new Rect(0, 0, 51, 51); btnPrev.SetCompoundDrawables(prevArrow, null, null, null); var lpbp = new LayoutParams(LayoutParams.WrapContent, LayoutParams.WrapContent); lpbp.AddRule(LayoutRules.AlignParentLeft); lpbp.AddRule(LayoutRules.CenterVertical); buttonBar.AddView(btnPrev, lpbp); var btnNext = new Button(Context) { Text = Resources.GetString(Resource.String.NextQuestion) + " ", TextSize = 14, Background = null, Visibility = QuestionNumber >= QuestionGroups[QuestionGroupName].Questions.Count - 1 ? ViewStates.Gone : ViewStates.Visible }; btnNext.SetTextSize(ComplexUnitType.Dip, 20); btnNext.Click += BtnNext_Click; var nextArrow = Resources.GetDrawable(Resource.Drawable.Next); nextArrow.Bounds = new Rect(0, 0, 51, 51); btnNext.SetCompoundDrawables(null, null, nextArrow, null); var lpbn = new LayoutParams(LayoutParams.WrapContent, LayoutParams.WrapContent); lpbn.AddRule(LayoutRules.AlignParentRight); lpbn.AddRule(LayoutRules.CenterVertical); buttonBar.AddView(btnNext, lpbn); var btnMenu = new Button(Context) { Text = Resources.GetString(Resource.String.BackToMainMenu) + " ", TextSize = 14, Background = null }; btnMenu.SetTextSize(ComplexUnitType.Dip, 20); btnMenu.Click += BtnMenu_Click; var lpbb = new LayoutParams(LayoutParams.WrapContent, LayoutParams.WrapContent); lpbb.AddRule(LayoutRules.CenterInParent); //lpbb.AddRule(LayoutRules.CenterVertical); buttonBar.AddView(btnMenu, lpbb); }
public override View GetSampleContent(Context con) { LinearLayout linear = new LinearLayout(con); linear.SetBackgroundColor(Android.Graphics.Color.White); linear.Orientation = Orientation.Vertical; linear.SetPadding(10, 10, 10, 10); TextView text2 = new TextView(con); text2.TextSize = 17; text2.TextAlignment = TextAlignment.Center; text2.Text = "This sample demonstrates how to insert and update the Table of Contents (TOC) in a Word document using Essential DocIO."; text2.SetTextColor(Android.Graphics.Color.ParseColor("#262626")); text2.SetPadding(5, 5, 5, 5); linear.AddView(text2); TextView space1 = new TextView(con); space1.TextSize = 10; linear.AddView(space1); m_context = con; LinearLayout radioLinearLayout = new LinearLayout(con); radioLinearLayout.Orientation = Orientation.Horizontal; TextView imageType = new TextView(con); imageType.Text = "Save As : "; imageType.TextSize = 19; radioLinearLayout.AddView(imageType); radioGroup = new RadioGroup(con); radioGroup.TextAlignment = TextAlignment.Center; radioGroup.Orientation = Orientation.Horizontal; docxButton = new RadioButton(con); docxButton.Text = "DOCX"; radioGroup.AddView(docxButton); pdfButton = new RadioButton(con); pdfButton.Text = "PDF"; radioGroup.AddView(pdfButton); radioGroup.Check(1); radioLinearLayout.AddView(radioGroup); linear.AddView(radioLinearLayout); docxButton.Checked = true; TextView space2 = new TextView(con); space2.TextSize = 10; linear.AddView(space2); Button generateButton = new Button(con); generateButton.Text = "Generate"; generateButton.Click += OnButtonClicked; linear.AddView(generateButton); return(linear); }
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); }; }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.Step1); //Android.Support.V7.Widget.Toolbar toolbar = FindViewById<Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar); //SetSupportActionBar(toolbar); //FindViewById<Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar).Title = "Create Droplet - Step 1"; //this.ActionBar.Title = "Create Droplet - Step 1"; //DrawerLayout drawer = FindViewById<DrawerLayout>(Resource.Id.drawer_layout); //ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar, Resource.String.navigation_drawer_open, Resource.String.navigation_drawer_close); //drawer.AddDrawerListener(toggle); //toggle.SyncState(); var CreatedDroplet = new DigitalOcean.API.Models.Requests.Droplet(); string[,] slugarr = { { "centos-7-x64", "CentOS 7 x64" }, { "debian-9-x64", "Debian 9 x64" }, { "fedora-30-x64", "Fedora 30 x64" }, { "ubuntu-19-04-x64", "Ubuntu 19.04 x64" } }; List <DistroDrops> distroDrops = new List <DistroDrops>(); EditText editText = FindViewById <EditText>(Resource.Id.Dropname); RadioGroup rg = FindViewById <RadioGroup>(Resource.Id.radiogroupdistro); for (int i = 0; i < slugarr.GetLength(0); i++) { RadioButton rdbtn = new RadioButton(this); rdbtn.Text = slugarr[i, 1]; rdbtn.Id = View.GenerateViewId(); rg.AddView(rdbtn); DistroDrops x = new DistroDrops(); x.radioid = rdbtn.Id; x.slug = slugarr[i, 0]; x.name = slugarr[i, 1]; distroDrops.Add(x); } RadioButton checkedrdbtn = FindViewById <RadioButton>(rg.CheckedRadioButtonId); rg.CheckedChange += (o, e) => { checkedrdbtn = FindViewById <RadioButton>(rg.CheckedRadioButtonId); for (int i = 0; i < distroDrops.Count; i++) { if (checkedrdbtn.Text == distroDrops[i].name) { CreatedDroplet.ImageIdOrSlug = distroDrops[i].slug; } } }; Button next = FindViewById <Button>(Resource.Id.NextS1); next.Click += (o, e) => { if (editText.Text == "") { Toast.MakeText(this, "Please enter name of droplet", ToastLength.Short).Show(); return; } if (checkedrdbtn == null) { Toast.MakeText(this, "Please select distro", ToastLength.Short).Show(); return; } var intent = new Intent(this, typeof(Step2Activity)); intent.PutExtra("dropletName", editText.Text); intent.PutExtra("DropletDistro", CreatedDroplet.ImageIdOrSlug.ToString()); StartActivity(intent); }; }
private void CreateRadio(Context context, ImageView indicatorImage) { RadioGroup radioContainer = new RadioGroup(context); //int randomID = Guid.NewGuid().GetHashCode(); if (myElement.IsVertical) { radioContainer.Orientation = Orientation.Vertical; } else { //radioContainer.Orientation = Orientation.Horizontal; radioContainer.Orientation = Orientation.Vertical; } int magicNumber = 867; for (int k = 0; k < checkBoxValues.Count; k++) { RadioButton r = new RadioButton(context) { Text = checkBoxValues[k].Name }; r.Id = magicNumber + k; r.SetPadding(15, 5, 10, 5); r.TextSize = 16; int i2 = k; if (checkBoxValues[k].Value == "true") { r.Checked = true; } r.CheckedChange += (o, e) => { r.RequestFocusFromTouch(); indicatorImage.SetImageResource(Resource.Drawable.checked_forms_create_project_medium); sharedPreferencesEditor.PutBoolean("ReportEditFlag", true); sharedPreferencesEditor.Commit(); if (r.Checked) { for (int j = 0; j < checkBoxValues.Count; j++) { checkBoxValues[j].Value = "false"; } checkBoxValues[i2].Value = "true"; if (ChildCount > 2) { RemoveViews(2, ChildCount - 2); } if (myElement.Values[i2].Condition) { for (int j = 0; j < myElement.Values[i2].Child[0].Count; j++) { AddView(getView(myElement.Values[i2].Child[0][j], myElement.Values[i2].Child[0])); } } } }; if (isArcheived) { r.Enabled = false; } if (OwnerID == 0 || OwnerID == UserID) { if (VerifierID != 0) { r.Enabled = false; if (reportStatus == ReportStatus.Rejected) { r.Enabled = true; } } else { r.Enabled = true; } } else { r.Enabled = false; } radioContainer.AddView(r); } if (myElement.IsVertical) { checkboxFrame.AddView(radioContainer); } else { checkHoriFrame.AddView(radioContainer); } }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); //Layouts LinearLayout layoutbase = FindViewById <LinearLayout>(Resource.Id.mainLinear); layoutbase.SetBackgroundColor(Color.DarkRed); RelativeLayout relativebase = new RelativeLayout(this); relativebase.SetBackgroundColor(Color.Transparent); //Gets the actual phones dimensions var met = Resources.DisplayMetrics; scrW = met.WidthPixels; scrH = met.HeightPixels; //New colors Color tBlack = new Color(0, 0, 0, 80); Color etxtHintColor = new Color(56, 56, 56); Color etxtFontColor = Color.Silver; //Color state list Android.Content.Res.ColorStateList cslRG = new Android.Content.Res.ColorStateList( new int[][] { new int[] { -Android.Resource.Attribute.StateEnabled }, new int[] { Android.Resource.Attribute.StateEnabled } }, new int[] { tBlack, Color.Silver }); //Item creations etxtDiff = new EditText(this) { InputType = Android.Text.InputTypes.ClassNumber, Hint = GetString(Resource.String.difficulty), Gravity = GravityFlags.Center }; etxtDiff.SetHintTextColor(etxtHintColor); etxtDiff.SetTextColor(etxtFontColor); etxtRoll = new EditText(this) { InputType = Android.Text.InputTypes.ClassNumber, Hint = GetString(Resource.String.roll), Gravity = GravityFlags.Center }; etxtRoll.SetHintTextColor(etxtHintColor); etxtRoll.SetTextColor(etxtFontColor); txtVResult = new TextView(this) { TextAlignment = TextAlignment.Gravity, Gravity = GravityFlags.Center, TextSize = 20, Text = Calculate(etxtDiff.Text, etxtRoll.Text), Id = Resource.String.idtxtResult }; txtVResult.SetTextColor(Color.Black); TextView txtDiff = new TextView(this) { Id = 99, Gravity = GravityFlags.Left, TextSize = 18, Text = GetString(Resource.String.diff_text) }; txtDiff.SetTextColor(Color.Black); ddlDiff = new Spinner(this) { Id = 98 }; //Radio group rgShooting1 = new RadioGroup(this) { Orientation = Orientation.Horizontal }; RadioButton[] rb1 = new RadioButton[3]; for (int i = 0; i < rb1.Length; i++) { rb1[i] = new RadioButton(this) { Text = GetString(GetShootingID(i)), Id = 100 + i, ButtonTintList = cslRG }; rb1[i].SetTextColor(Color.Goldenrod); rb1[i].Click += RBRangeDeselect_Click; rgShooting1.AddView(rb1[i]); } rgShooting2 = new RadioGroup(this) { Orientation = Orientation.Horizontal }; RadioButton[] rb2 = new RadioButton[2]; for (int i = 0; i < rb2.Length; i++) { rb2[i] = new RadioButton(this) { Text = GetString(GetShootingID(i + 3)), Id = 103 + i, ButtonTintList = cslRG }; rb2[i].SetTextColor(Color.Goldenrod); rb2[i].Click += RBRangeDeselect_Click; rgShooting2.AddView(rb2[i]); } rgShooting1.ClearCheck(); rgShooting2.ClearCheck(); rgShootMode = new RadioGroup(this) { Orientation = Orientation.Horizontal }; RadioButton[] rbMode = new RadioButton[3]; for (int i = 0; i < rbMode.Length; i++) { rbMode[i] = new RadioButton(this) { Text = GetString(GetShotModeId(i)), Id = 200 + i, Gravity = GravityFlags.Center, ButtonTintList = cslRG }; rbMode[i].SetTextColor(Color.Goldenrod); rgShootMode.AddView(rbMode[i]); } rgShootMode.ClearCheck(); //Create layouts LinearLayout.LayoutParams llpMW = new LinearLayout.LayoutParams(LayoutParams.MatchParent, LayoutParams.WrapContent); LinearLayout.LayoutParams llpMWBM40 = new LinearLayout.LayoutParams(LayoutParams.MatchParent, LayoutParams.WrapContent) { BottomMargin = 40 }; LinearLayout.LayoutParams llpMWBM80 = new LinearLayout.LayoutParams(LayoutParams.MatchParent, LayoutParams.WrapContent) { BottomMargin = 80 }; LinearLayout.LayoutParams llpTxtDiff = new LinearLayout.LayoutParams(MathCeiling(scrW, 0.4), LayoutParams.WrapContent) { BottomMargin = 40, Gravity = GravityFlags.Left }; LinearLayout.LayoutParams llpDdlDiff = new LinearLayout.LayoutParams(MathCeiling(scrW, 0.44), LayoutParams.WrapContent) { BottomMargin = 40, Gravity = GravityFlags.Right }; LinearLayout.LayoutParams llpWWC = new LinearLayout.LayoutParams(LayoutParams.WrapContent, LayoutParams.WrapContent) { Gravity = GravityFlags.Center }; RelativeLayout.LayoutParams rlpRlo = new RelativeLayout.LayoutParams(scrW, scrH); RelativeLayout.LayoutParams rlpTxtDiff = new RelativeLayout.LayoutParams(MathCeiling(scrW, 0.4), LayoutParams.WrapContent) { LeftMargin = MathCeiling(scrW, 0.1), TopMargin = 20, BottomMargin = 40 }; rlpTxtDiff.AddRule(LayoutRules.AlignParentLeft); RelativeLayout.LayoutParams rlpDdlDiff = new RelativeLayout.LayoutParams(MathCeiling(scrW, 0.44), LayoutParams.WrapContent) { TopMargin = 20, BottomMargin = 40 }; rlpDdlDiff.AddRule(LayoutRules.AlignParentRight); //Add layouts etxtDiff.LayoutParameters = llpMW; ddlDiff.LayoutParameters = rlpDdlDiff; txtDiff.LayoutParameters = rlpTxtDiff; etxtRoll.LayoutParameters = llpMWBM40; txtVResult.LayoutParameters = llpMWBM80; rgShooting1.LayoutParameters = llpMW; rgShooting2.LayoutParameters = llpWWC; rgShootMode.LayoutParameters = llpMW; //Drop down items var diffArrays = ArrayAdapter.CreateFromResource(this, Resource.Array.difficulty_array, Resource.Layout.spinner_item); diffArrays.SetDropDownViewResource(Resource.Layout.spinner_dd_items); ddlDiff.Adapter = diffArrays; ddlDiff.SetSelection(diffArrays.GetPosition("Challenging +0")); //Add methods etxtDiff.TextChanged += ResultChanger; etxtRoll.TextChanged += ResultChanger; ddlDiff.ItemSelected += DdlDiff_ItemSelected; rgShooting1.CheckedChange += RgShooting1_CheckedChange; rgShooting2.CheckedChange += RgShooting2_CheckedChange; rgShootMode.CheckedChange += RgShootMode_CheckedChange; //Order of insertion layoutbase.AddView(etxtDiff); layoutbase.AddView(etxtRoll); layoutbase.AddView(txtVResult); layoutbase.AddView(AddLine(8000)); relativebase.AddView(txtDiff); relativebase.AddView(ddlDiff); layoutbase.AddView(relativebase); //layoutbase.AddView(txtDiff); //layoutbase.AddView(ddlDiff); layoutbase.AddView(AddLine(8001)); layoutbase.AddView(rgShooting1); layoutbase.AddView(rgShooting2); layoutbase.AddView(AddLine(8002)); layoutbase.AddView(rgShootMode); //Layout layoutbase.Click += MainActivity_Click; imm = (InputMethodManager)GetSystemService(InputMethodService); }