public bool SetTypeface(Typeface typeface, TypefaceStyle style = TypefaceStyle.Normal) { if (m_viewX is Button) { ((Button)m_viewX).SetTypeface(typeface, style); } else if (m_viewX is TextView) { ((TextView)m_viewX).SetTypeface(typeface, style); } else if (m_viewX is EditText) { ((EditText)m_viewX).SetTypeface(typeface, style); } else if (m_viewX is Switch) { ((Switch)m_viewX).SetTypeface(typeface, style); } else if (m_viewX is Spinner) { Spinner spinner = (Spinner)m_viewX; TextImageAdapter adapter = spinner.Adapter as TextImageAdapter; if (adapter != null) { adapter.Typeface = typeface; adapter.TypefaceStyle = style; } } else { return(false); } return(true); }
public bool SetFontSize(View view, float fontSize) { if (view is Button) { ((Button)view).TextSize = fontSize; } else if (view is TextView) { ((TextView)view).TextSize = fontSize; } else if (view is EditText) { ((EditText)view).TextSize = fontSize; } else if (view is Switch) { ((Switch)ViewX).TextSize = fontSize; } else if (view is Spinner) { Spinner spinner = (Spinner)view; TextImageAdapter adapter = spinner.Adapter as TextImageAdapter; if (adapter != null) { adapter.TextSize = fontSize; } } else { return(false); } return(true); }
public virtual void AddImages(List <string> images, string varName, string title) { if (ViewX is Spinner) { Spinner spinner = ViewX as Spinner; var adapter = spinner.Adapter as TextImageAdapter; if (adapter == null) { adapter = new TextImageAdapter(MainActivity.TheView); } adapter.SetPics(images); spinner.Adapter = adapter; if (!string.IsNullOrEmpty(title)) { AddAction(varName, title); } } else if (ViewX is ListView) { ListView listView = ViewX as ListView; var adapter = listView.Adapter as TextImageAdapter; if (adapter == null) { adapter = new TextImageAdapter(MainActivity.TheView); } adapter.SetPics(images); listView.Adapter = adapter; if (!string.IsNullOrEmpty(title)) { AddAction(varName, title); } } }
public virtual void AddData(List <string> data, string varName, string title, string extra) { if (ViewX is NumberPicker) { NumberPicker pickerView = ViewX as NumberPicker; pickerView.SaveFromParentEnabled = false; pickerView.SaveEnabled = true; pickerView.SetDisplayedValues(data.ToArray()); pickerView.MinValue = 0; pickerView.MaxValue = data.Count - 1; pickerView.Value = 0; pickerView.WrapSelectorWheel = false; AddAction(varName, title); } else if (ViewX is Spinner) { Spinner spinner = ViewX as Spinner; var adapter = spinner.Adapter as TextImageAdapter; if (adapter == null) { adapter = new TextImageAdapter(MainActivity.TheView); } string first = null;//InitValue == null ? null : InitValue.AsString(); adapter.SetItems(data, first); spinner.Adapter = adapter; AddAction(varName, title); } else if (ViewX is ListView) { ListView listView = ViewX as ListView; var adapter = listView.Adapter as TextImageAdapter; if (adapter == null) { adapter = new TextImageAdapter(MainActivity.TheView); } adapter.SetItems(data); listView.Adapter = adapter; AddAction(varName, title); } }
public virtual bool SetText(string text, string alignment = null) { AlignText(alignment); if (ViewX is Button) { ((Button)ViewX).Text = text; } else if (ViewX is TextView) { ((TextView)ViewX).Text = text; } else if (ViewX is EditText) { ((EditText)ViewX).Text = text; } else if (ViewX is Spinner) { Spinner spinner = ViewX as Spinner; TextImageAdapter adapter = spinner.Adapter as TextImageAdapter; if (adapter != null) { int pos = adapter.Text2Position(text); spinner.SetSelection(pos); } } else if (ViewX is NumberPicker) { NumberPicker picker = ViewX as NumberPicker; string[] all = picker.GetDisplayedValues(); List <string> names = new List <string>(all); int row = names.FindIndex((obj) => obj.Equals(text)); picker.Value = (int)row; ExecuteAction(row.ToString()); } else { return(false); } return(true); }
public virtual string GetText() { string text = ""; if (ViewX is Button) { text = ((Button)ViewX).Text; } else if (ViewX is TextView) { text = ((TextView)ViewX).Text; } else if (ViewX is EditText) { text = ((EditText)ViewX).Text; } else if (ViewX is Spinner) { Spinner spinner = ViewX as Spinner; TextImageAdapter adapter = spinner.Adapter as TextImageAdapter; if (adapter != null) { int pos = spinner.SelectedItemPosition; text = adapter.Position2Text(pos); } } else if (ViewX is NumberPicker) { NumberPicker picker = ViewX as NumberPicker; string[] all = picker.GetDisplayedValues(); int row = picker.Value; if (all.Length > row && row >= 0) { text = all[row]; } } return(text); }