private void Generate_Table(List <TestHelper.Question> questions, bool show_wrong_inputs) { TableLayout table = FindViewById <TableLayout>(Resource.Id.tableAnswers); foreach (TestHelper.Question question in questions) { TextView text_value = new TextView(this); text_value.Text = question.value; TextView text_wrong_answers = new TextView(this); text_wrong_answers.Text = question.wrong_answers.ToString(); if (show_wrong_inputs) { text_wrong_answers.Text += string.Format(" ({0})", question.wrong_inputs); } text_wrong_answers.Gravity = GravityFlags.CenterHorizontal; if (question.wrong_answers > 0) { text_value.SetTextColor(Android.Graphics.Color.Red); text_wrong_answers.SetTextColor(Android.Graphics.Color.Red); } TableRow row = new TableRow(this); if (question.is_old) { row.SetBackgroundColor(Android.Graphics.Color.LightGray); } row.AddView(text_value); row.AddView(text_wrong_answers); table.AddView(row); } }
void AddProductosDescripcion() { productos.AsParallel().ToList().ForEach(precio => { TableRow trDescripcion = new TableRow(this); TextView lblCantidad = new TextView(this) { Text = precio.Carrito_Compras_Detalle_Cantidad }; trDescripcion.AddView(lblCantidad, 0); TextView lblDescripcion = new TextView(this) { Text = precio.Carrito_Compras_Detalle_Descripcion }; lblDescripcion.SetWidth(120); lblDescripcion.Click += (sender, e) => ShowDesglose(precio); trDescripcion.AddView(lblDescripcion, 1); TextView lblTotal = new TextView(this) { Text = precio.Carrito_Compras_Detalle_Importe_Suma_Texto }; trDescripcion.AddView(lblTotal, 2); tlCarrito.AddView(trDescripcion); Subtotal += Convert.ToDecimal(precio.Carrito_Compras_Detalle_Importe_Suma); }); }
public static void InitDataDisplayView(Context context, TableLayout table, string fileName) { try { JSONObject jsonObject = new JSONObject(GetJson(context, fileName)); IIterator iterator = jsonObject.Keys(); while (iterator.HasNext) { string key = (string)iterator.Next(); string value = jsonObject.GetString(key); TableRow tableRow = new TableRow(context); TextView textView = new TextView(context); textView.Text = key; textView.SetTextColor(Color.Gray); textView.Id = context.Resources.GetIdentifier(key + "_key", "id", context.PackageName); tableRow.AddView(textView); EditText editText = new EditText(context); editText.Text = value; editText.Id = context.Resources .GetIdentifier(key + "_value", "id", context.PackageName); editText.SetTextColor(Color.DarkGray); tableRow.AddView(editText); table.AddView(tableRow); } } catch (JSONException e) { Log.Error("Utils.InitDataDisplayView", $"JSONException occured: {e.Message}"); } }
public TableViewOld(Activity context, TableController controller) : this() { this.controller = controller; this.parentActivity = context; table_view = context.LayoutInflater.Inflate(Resource.Layout.TableLayoutOld, null); tableView = table_view.FindViewById <TableLayout>(Resource.Id.table_data); column_row_view = table_view.FindViewById <TableRow>(Resource.Id.columnRow); deleteButton = table_view.FindViewById <ImageButton>(Resource.Id.deleteButton); deleteButton.SetOnClickListener(this); tableName = table_view.FindViewById <EditText>(Resource.Id.nameEdit); nameListener = new NameChangeListener(this); tableName.AddTextChangedListener(nameListener); checkBoxView = new CheckBox(context); onCheckedListener = new OnCheckedListener(this); checkBoxView.SetOnCheckedChangeListener(onCheckedListener); column_row_view.AddView(checkBoxView); View dummy = new View(context); column_row_view.AddView(dummy); //controller.HookView(this); }
private void UpdateMemoryTableUI() { tlData.RemoveAllViews(); foreach (var memoryItem in store.Items) { TableRow tr = new TableRow(this); var rowColor = Color.White; tr.SetBackgroundColor(rowColor); var cellColor = Color.Black; var txtVal1 = new TextView(this) { Text = memoryItem.Values[0] }; txtVal1.SetPadding(1, 1, 1, 1); tr.AddView(txtVal1); txtVal1.SetBackgroundColor(cellColor); var txtVal2 = new TextView(this) { Text = memoryItem.Values[1] }; txtVal2.SetPadding(1, 1, 1, 1); txtVal2.SetBackgroundColor(cellColor); tr.AddView(txtVal2); tlData.AddView(tr); } }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); ScrollView scrollView = new ScrollView(this); TableLayout tableLayout = new TableLayout(this); TableRow tablerow = new TableRow(this); // make columns span the whole width tableLayout.SetColumnStretchable(0, true); tableLayout.SetColumnStretchable(1, true); TextView DepartCollumn = new TextView(this); DepartCollumn.Text = "Depart"; tablerow.AddView(DepartCollumn); TimetableList.TimeColumns.Add(DepartCollumn); TextView ArriveCollumn = new TextView(this); ArriveCollumn.Text = "Arrive"; tablerow.AddView(ArriveCollumn); TimetableList.TimeColumns.Add(ArriveCollumn); tableLayout.AddView(tablerow); // tableLayout.SetScrollContainer(true); scrollView.AddView(tableLayout); SetContentView(scrollView); }
private void ShowGeneratedRoutes() //drawing UI elements needs to be fixed { TableLayout layout = FindViewById <TableLayout>(Resource.Id.routeList); foreach (var route in _generatedRoutes) { var text = new TextView(this); text.Text = route.ToString(); text.SetTextColor(new Color(252, 177, 80)); //our orange text.SetTextSize(Android.Util.ComplexUnitType.Pt, 7); //text.SetWidth(); //text.SetHeight(); TableRow.LayoutParams par = new TableRow.LayoutParams(); par.SetMargins(100, 0, 0, 0); var button = new Button(this); button.Text = "Pirkti"; button.Background = Resources.GetDrawable(Resource.Drawable.OrangeActionBtn); //deprecated but f**k it button.SetTextColor(Color.White); button.Click += (obj, evnt) => { Order(route); }; var tableRow = new TableRow(this); tableRow.SetMinimumHeight(250); tableRow.AddView(text); tableRow.AddView(button, par); layout.AddView(tableRow); } }
public void addRole(ref int count) { cb = new CheckBox(this); tv_view1 = new TextView(this); if (count < 10) { tv_view1.Text = "0" + count; } else { tv_view1.Text = "" + count; } count++; tv_view2 = new TextView(this); tv_view2.Text = "test"; tv_view3 = new TextView(this); tv_view3.Text = "test"; tv_view4 = new TextView(this); tv_view4.Text = "1"; tb = new TableRow(this); tb.AddView(cb); tb.AddView(tv_view1); tb.AddView(tv_view2); tb.AddView(tv_view3); tb.AddView(tv_view4); tl_view.AddView(tb); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); account_id = Intent.GetStringExtra("account_id"); SetContentView(Resource.Layout.TotalsReport); Title = "Fund Totals - " + Db.getAccount(account_id).account_name; var scrollview = FindViewById<ScrollView>(Resource.Id.scrollview); var t = new TableLayout(this); t.StretchAllColumns = true; foreach (Fund f in Db.getFunds()) { var tr = new TableRow(this); var tdFundName = new TextView(this); tdFundName.Text = f.fund_name; tdFundName.Tag = f.fund_id; tdFundName.Click += Fund_Click; tr.AddView(tdFundName); var tdAmount = new TextView(this); tdAmount.Tag = f.fund_id; tdAmount.Click += Fund_Click; tdAmount.Text = String.Format("{0:C}", Db.getFundTotal(account_id: account_id, fund_id: f.fund_id)); tdAmount.Gravity = GravityFlags.Right; tr.AddView(tdAmount); t.AddView(tr); } scrollview.AddView(t); }
void AddMembresiaDescripcion() { membresias.AsParallel().ToList().ForEach(precio => { TableRow trDescripcion = new TableRow(this); TextView lblCantidad = new TextView(this) { Text = precio.Carrito_Compras_Detalle_Cantidad }; lblCantidad.SetTextColor(Color.ParseColor("#767676")); trDescripcion.AddView(lblCantidad, 0); TextView lblDescripcion = new TextView(this) { Text = precio.Carrito_Compras_Detalle_Descripcion }; lblDescripcion.SetTextColor(Color.ParseColor("#767676")); lblDescripcion.SetWidth(120); lblDescripcion.Click += (sender, e) => ShowDesglose(precio); trDescripcion.AddView(lblDescripcion, 1); TextView lblTotal = new TextView(this) { Text = Convert.ToDecimal(precio.Carrito_Compras_Detalle_Importe_Suma) != 0 ? precio.Carrito_Compras_Detalle_Importe_Suma_Texto : Convert.ToDecimal(precio.Carrito_Compras_Detalle_Importe_Prorrateo).ToString("C", System.Globalization.CultureInfo.GetCultureInfo("es-mx")) + "MXN" }; lblTotal.SetTextColor(Color.ParseColor("#767676")); trDescripcion.AddView(lblTotal, 2); tlCarrito.AddView(trDescripcion); Subtotal += Convert.ToDecimal(precio.Carrito_Compras_Detalle_Importe_Suma) != 0 ? Convert.ToDecimal(precio.Carrito_Compras_Detalle_Importe_Suma) : Convert.ToDecimal(precio.Carrito_Compras_Detalle_Importe_Prorrateo); }); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.activity_results); Android.Support.V7.App.ActionBar actionBar = SupportActionBar; if (actionBar != null) { actionBar.SetDisplayHomeAsUpEnabled(true); } TableLayout tl = FindViewById <TableLayout>(Resource.Id.tablelayout_contents); TableRow tr; TextView tv; List <string[]> data = ReadData(); foreach (string[] row in data) { tr = new TableRow(this); foreach (string cell in row) { tv = new TextView(this); tv.Background = ContextCompat.GetDrawable(this, Android.Resource.Drawable.EditBoxBackground); tv.Text = cell; tr.AddView(tv); } tl.AddView(tr); } string[] header = Resources.GetStringArray(Resource.Array.results_headers); tr = FindViewById <TableRow>(Resource.Id.tablerow_header); foreach (string cell in header) { tv = new TextView(this) { Background = ContextCompat.GetDrawable(this, Android.Resource.Drawable.EditBoxBackground), Text = cell }; tr.AddView(tv); } tl.ViewTreeObserver.GlobalLayout += (sender, args) => { TableRow trH; TextView tvH; trH = FindViewById <TableRow>(Resource.Id.tablerow_header); // if (tl.ChildCount > 0) for (int i = 0; i < tl.ChildCount; i++) { // tr = (TableRow)tl.GetChildAt(0); tr = (TableRow)tl.GetChildAt(i); for (int j = 0; j < tr.ChildCount; j++) { tv = (TextView)tr.GetChildAt(j); tvH = (TextView)trH.GetChildAt(j); tvH.SetWidth(tv.Width); } } }; }
public void Initiate(List <CellModel> cells, List <ColumnModel> columns) { foreach (CellModel model in cells) { CellView v = model.GetView(context); this.cells.Add(v); row_view.AddView(v.GetView()); } }
public List <FavoriteElementId> SetTableData(List <FavoriteData> favorites, Context context, Resources resources, TableLayout mTableLayout) { while (mTableLayout.ChildCount > 0) { mTableLayout.RemoveViewAt(0); } TableRow.LayoutParams tableRowLayoutparams = new TableRow.LayoutParams( ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent); List <FavoriteElementId> response = new List <FavoriteElementId>(); Boolean colored = true; foreach (FavoriteData Row in favorites) { TableRow tr = new TableRow(context); if (colored) { tr.SetBackgroundColor(resources.GetColor(Resource.Color.eventRowResult)); } colored = !colored; tr.LayoutParameters = tableRowLayoutparams; Boolean WITH_DIRECTION = Row.direction != null; TextView tv1 = new TextView(context); tv1.Text = Row.name + (WITH_DIRECTION ? " " + Row.direction : ""); tv1.TextAlignment = TextAlignment.ViewEnd; tv1.SetPadding(0, 0, 13, 0); tv1.SetMinimumWidth(320); tv1.SetTextSize(Android.Util.ComplexUnitType.Dip, WITH_DIRECTION ? 14 : 22); tv1.SetMaxWidth(1000); ImageButton deleteBtn = new ImageButton(context); deleteBtn.SetImageResource(Android.Resource.Drawable.IcMenuDelete); deleteBtn.SetMaxWidth(30); deleteBtn.SetBackgroundColor(Android.Graphics.Color.Transparent); deleteBtn.TextAlignment = TextAlignment.ViewEnd; tr.AddView(tv1); tr.AddView(deleteBtn); mTableLayout.AddView(tr); if (Row.direction == null) { response.Add(new FavoriteElementId(deleteBtn, tv1, Row.name, Row.searchType)); } else { response.Add(new FavoriteLineElementId(deleteBtn, tv1, Row.name, Row.searchType, Row.direction)); } } return(response); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); TableLayout playsTable = FindViewById <TableLayout>(Resource.Id.PlaysTable); string applicationDirectory = System.IO.Path.Combine("/storage", "emulated", "legacy", "Phonograph"); if (!System.IO.Directory.Exists(applicationDirectory)) { System.IO.Directory.CreateDirectory(applicationDirectory); } string databasePath = System.IO.Path.Combine(applicationDirectory, "PlaysDatabase.sqlite3"); var pdb = new Phonograph.Model.PhonographDatabase(databasePath); var plays = pdb.Query <PlaysView>( @"select p.id as ""Id"", t.title as ""TrackTitle"", a.title as ""AlbumTitle"", ar.name as ""ArtistName"", s.name as ""SourceName"", p.time as ""Time"" from plays p inner join tracks t on p.track_id = t.id inner join albums a on t.album_id = a.id inner join artists ar on t.artist_id = ar.id inner join sources s on p.source_id = s.id order by p.time desc limit 200"); foreach (var p in plays) { TableRow newRow = new TableRow(this); TextView tvTrack = new TextView(this); tvTrack.SetText(p.TrackTitle, TextView.BufferType.Normal); TextView tvArtist = new TextView(this); tvArtist.SetText(p.ArtistName, TextView.BufferType.Normal); TextView tvAlbum = new TextView(this); tvAlbum.SetText(p.AlbumTitle, TextView.BufferType.Normal); TextView tvSource = new TextView(this); tvSource.SetText(p.SourceName, TextView.BufferType.Normal); TextView tvTime = new TextView(this); tvTime.SetText(p.Time.ToString(), TextView.BufferType.Normal); newRow.AddView(tvTrack); newRow.AddView(tvArtist); newRow.AddView(tvAlbum); newRow.AddView(tvSource); newRow.AddView(tvTime); playsTable.AddView(newRow); } StartService(new Intent(this, typeof(PhonographService))); }
private TableRow CreateRow(string indexField, string senderNameField, string hearthCountField, string timeField, bool isHeader = false) { TableRow row = new TableRow(this); TableRow.LayoutParams layoutParams = new TableRow.LayoutParams(TableRow.LayoutParams.MatchParent); row.LayoutParameters = layoutParams; TextView numberTextView = new TextView(this); TextView usernameTextView = new TextView(this); TextView heartCountTextView = new TextView(this); TextView receiveTimeTextView = new TextView(this); numberTextView.SetPadding(0, 2, 10, 2); usernameTextView.SetPadding(3, 2, 3, 2); heartCountTextView.SetPadding(3, 2, 3, 2); receiveTimeTextView.SetPadding(3, 2, 0, 2); heartCountTextView.SetMinWidth(35); numberTextView.SetText(indexField, TextView.BufferType.Normal); usernameTextView.SetText(senderNameField, TextView.BufferType.Normal); heartCountTextView.SetText(hearthCountField, TextView.BufferType.Normal); receiveTimeTextView.SetText(timeField, TextView.BufferType.Normal); if (isHeader) { numberTextView.SetTypeface(null, Android.Graphics.TypefaceStyle.Bold); usernameTextView.SetTypeface(null, Android.Graphics.TypefaceStyle.Bold); heartCountTextView.SetTypeface(null, Android.Graphics.TypefaceStyle.Bold); receiveTimeTextView.SetTypeface(null, Android.Graphics.TypefaceStyle.Bold); numberTextView.SetTextSize(ComplexUnitType.Sp, (numberTextView.TextSize * 1.25f) / Resources.DisplayMetrics.Density); usernameTextView.SetTextSize(ComplexUnitType.Sp, (usernameTextView.TextSize * 1.25f) / Resources.DisplayMetrics.Density); heartCountTextView.SetTextSize(ComplexUnitType.Sp, (heartCountTextView.TextSize * 1.25f) / Resources.DisplayMetrics.Density); receiveTimeTextView.SetTextSize(ComplexUnitType.Sp, (receiveTimeTextView.TextSize * 1.25f) / Resources.DisplayMetrics.Density); } numberTextView.LayoutParameters = new TableRow.LayoutParams(TableRow.LayoutParams.WrapContent, TableRow.LayoutParams.WrapContent); usernameTextView.LayoutParameters = new TableRow.LayoutParams(TableRow.LayoutParams.WrapContent, TableRow.LayoutParams.WrapContent, 0.6f); heartCountTextView.LayoutParameters = new TableRow.LayoutParams(TableRow.LayoutParams.WrapContent, TableRow.LayoutParams.WrapContent, 0.4f); receiveTimeTextView.LayoutParameters = new TableRow.LayoutParams(TableRow.LayoutParams.WrapContent, TableRow.LayoutParams.WrapContent); receiveTimeTextView.TextAlignment = TextAlignment.ViewEnd; row.AddView(numberTextView); row.AddView(usernameTextView); row.AddView(heartCountTextView); row.AddView(receiveTimeTextView); return(row); }
/// <summary> /// Получение текущих установок для спутников /// </summary> /// <param name="settingsFileName">Файл настроек</param> private void RetrieveSettings(string settingsFileName) { try { var satellites = SatelliteSettings.Impl.Read(settingsFileName); if (satellites == null || satellites.Count == 0) { return; } _motionParams.AddRange(satellites); _motionParams.ForEach(satellite => { var roundingTime = satellite.RoundingTime; using (var tableRow = new TableRow(this)) { int nextId; using (var speedText = new EditText(this) { InputType = InputTypes.ClassNumber, Text = roundingTime.ToString(), Id = UniqueIdGen.NextId }) { speedText.SetMaxLines(1); _currentRecordId = speedText.Id; nextId = speedText.Id + 1; tableRow.AddView(speedText); } using (var distanceText = new EditText(this) { InputType = InputTypes.ClassNumber | InputTypes.NumberFlagDecimal, Text = satellite.Distance.ToString(CultureInfo.CurrentCulture), Id = nextId }) { distanceText.SetMaxLines(1); tableRow.AddView(distanceText); } _settingsTable.AddView(tableRow); } }); } catch (Exception ex) { Log.Info(GetType().Name, ex.Message, ex); } }
private void UpdateListView() { var table = FindViewById <TableLayout>(Resource.Id.tableLayout1); var layout = new TableRow.LayoutParams( ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent); // clear the table apart from header if (table.ChildCount > 1) { table.RemoveViews(1, table.ChildCount - 1); } foreach (var pair in activeDownloads) { TableRow row = new TableRow(this); TextView text = new TextView(this) { Text = pair.Value.Name }; text.SetMaxWidth(160); text.SetMinWidth(160); text.LayoutParameters = layout; row.AddView(text, 0); text = new TextView(this) { Text = pair.Value.Progress }; text.LayoutParameters = layout; row.AddView(text, 1); text = new TextView(this) { Text = pair.Value.State }; text.LayoutParameters = layout; row.AddView(text, 2); // change colour if (table.ChildCount % 2 == 0) { row.SetBackgroundColor(Android.Graphics.Color.LightBlue); } table.AddView(row, layout); } }
/* MyFuncs */ void MakeTableHeader() { TableRow view = (TableRow)inflater.Inflate(Resource.Layout.TableRowHeader, null); view.FindViewById <TextView> (Resource.Id.txtFIO).Text = "ФИО"; listOfWeekNum = new List <int> (); int delta = 0; var min = ReportManager.GetMinWeekNum(); for (int i = 0; i < 12; i++) { if ((min + i) % 53 == 0) { delta = 1; } listOfWeekNum.Add((min + i + delta) % 53); } foreach (int weekNum in listOfWeekNum) { TextView txtWeekNum = (TextView)inflater.Inflate(Resource.Layout.TableWeekNum, null); txtWeekNum.Text = weekNum.ToString(); view.AddView(txtWeekNum); } tlHeader.AddView(view); }
private void drawItems(List <XElement> items, TableLayout tableLayout, TableRow tableRow) { foreach (var it in items) { var codeData = new List <string>() { it.Attribute("series").Value, it.Attribute("order").Value, it.Attribute("type").Value //it.Attribute("brend").Value }; for (int i = 0; i < codeData.Count; i++) { var txt = "<b>"; if (i == 0) { txt += "Серия:"; } else if (i == 1) { txt += "Заказной код:"; } else if (i == 2) { txt += "Типовой код:"; } //else if (i == 3) // txt += "Бренд:"; txt += "</b> "; txtView = new TextView(this); txtView.SetText(Html.FromHtml(txt + codeData[i]), TextView.BufferType.Editable); txtView.SetBackgroundResource(Resource.Layout.finded); txtView.Gravity = GravityFlags.Left; txtView.SetPadding(25, 25, 25, 25); txtView.SetTextColor(Color.Black); //txtView.SetTypeface(Typeface.Default, TypefaceStyle.Bold); tableRow = new TableRow(this); tableRow.LayoutParameters = new TableRow.LayoutParams(TableRow.LayoutParams.WrapContent, TableRow.LayoutParams.MatchParent); tableRow.AddView(txtView); tableLayout.AddView(tableRow); } txtView = new TextView(this); txtView.SetText(Html.FromHtml(""), TextView.BufferType.Editable); txtView.Gravity = GravityFlags.Left; txtView.SetPadding(25, 25, 25, 25); txtView.SetTextColor(Color.Black); //txtView.SetTypeface(Typeface.Default, TypefaceStyle.Normal); tableRow = new TableRow(this); tableRow.LayoutParameters = new TableRow.LayoutParams(TableRow.LayoutParams.WrapContent, TableRow.LayoutParams.MatchParent); tableRow.AddView(txtView); tableLayout.AddView(tableRow); } }
/// <summary> /// Build a table row with weather icons and text /// </summary> private TableRow BuildWeatherRow(string previous, string current, string eorzeaHour, string localTime) { var tableRow = new TableRow(_view.Context); var prev = Helpers.BuildImageView(previous, _view.Context, previous, pad: (10, 0, 10, 0)); var cur = Helpers.BuildImageView(current, _view.Context, current, pad: (10, 0, 10, 0)); var et = Helpers.BuildTextView(Helpers.FormatEorzeaHour(eorzeaHour), _view.Context, pad: (10, 0, 10, 0)); var lt = Helpers.BuildTextView(localTime, _view.Context, pad: (10, 0, 10, 0)); tableRow.AddView(prev); tableRow.AddView(cur); tableRow.AddView(et); tableRow.AddView(lt); return(tableRow); }
private static TableRow CreateRow(Context context, View leftTextView, View rightTextView, GridLength leftColumnWidth, GridLength rightColumnWidth) { var tableRow = new TableRow(context); var linearLayout = new LinearLayout(context) { WeightSum = (float)1.0 }; //This is a little counter intuitive, but the Left Text View needs to be set to the Right Column Width var leftTextViewLayout = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent) { Weight = (float)rightColumnWidth.Value }; leftTextView.LayoutParameters = leftTextViewLayout; linearLayout.AddView(leftTextView); var rightTextViewLayout = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent) { Weight = (float)leftColumnWidth.Value }; rightTextView.LayoutParameters = rightTextViewLayout; linearLayout.AddView(rightTextView); tableRow.AddView(linearLayout); return(tableRow); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); //set view SetContentView(Resource.Layout.SelectView); TextView Lab_RowTitle = FindViewById <TextView>(Resource.Id.Lab_RowTitle); Lab_RowTitle.Text = "時間"; //get Data // 得到跳转到该Activity的Intent对象 Bundle bundle = Intent.GetBundleExtra("bundle"); List <string> timelist = bundle.GetStringArrayList("timelist").ToList(); //Create your application here TableLayout MainTable = FindViewById <TableLayout>(Resource.Id.table_city); Button b; TableRow tr; for (int i = 0; i < timelist.Count; i++) { tr = new TableRow(this); b = new Button(this); string time = timelist[i].Substring(1, timelist[i].Length - 2); b.Text = time; b.Click += delegate { CreatNewSelect("4"); }; tr.AddView(b); MainTable.AddView(tr); } }
void FillHistorial() { TableLayout table = SalasView.FindViewById <TableLayout>(Resource.Id.historial_table); table.RemoveAllViews(); historico.AsParallel().ToList().ForEach(reservacion => { LayoutInflater inflater = (LayoutInflater)context.GetSystemService(Context.LayoutInflaterService); View ReservaView = inflater.Inflate(Resource.Layout.ReservacionElementoLayout, null, true); ReservaView.FindViewById <GridLayout>(Resource.Id.glReservacion).SetMinimumWidth(context.Resources.DisplayMetrics.WidthPixels); ReservaView.FindViewById <TextView>(Resource.Id.lblSalaJunta).Text = reservacion.Sala_Descripcion; ReservaView.FindViewById <TextView>(Resource.Id.lblDiaSemana).Text = DateTime.Parse(reservacion.Sala_Fecha).Day.ToString(); ReservaView.FindViewById <TextView>(Resource.Id.lblDia).Text = DateTime.Parse(reservacion.Sala_Fecha).DayOfWeek.ToString(); ReservaView.FindViewById <TextView>(Resource.Id.lblHorario).Text = reservacion.Sala_Hora_Inicio.Substring(0, 5) + " - " + reservacion.Sala_Hora_Fin.Substring(0, 5); ReservaView.FindViewById <ImageButton>(Resource.Id.btnCancelar).Click += delegate { if (controller.CancelarSalaJuntas("Baja", reservacion.Sala_Junta_Reservacion_Id)) { Toast.MakeText(context, Resource.String.str_meeting_room_canceled, ToastLength.Short).Show(); historico.Remove(reservacion); HistorialValidation(); } else { Toast.MakeText(context, Resource.String.ErrorIntento, ToastLength.Short).Show(); } }; TableRow row = new TableRow(context); row.AddView(ReservaView); table.AddView(row); }); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); // Create your application here var container = new LinearLayout(this) { Background = Android.Graphics.Color.Yellow.ToDrawable(), }; SetContentView(container); var table = new TableLayout(this) { Background = Android.Graphics.Color.Red.ToDrawable(), StretchAllColumns = true, // カラムを均等割にする WeightSum = rows, // 行を均等割にしたいので行数を指定 }; container.AddView(table, new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MatchParent, // 幅は親に合わせる LinearLayout.LayoutParams.MatchParent) // 高さは親に合わせる ); for (int i = 0; i < rows; i++) { var rowlayouts = new TableLayout.LayoutParams( TableLayout.LayoutParams.WrapContent, TableLayout.LayoutParams.WrapContent) { Weight = 1, // テーブルの中で均等割するので全ての重みを1にする Height = 0 // 高さを自動指定 }; var row = new TableRow(this); table.AddView(row, rowlayouts); for (int j = 0; j < cols; j++) { var buttonlayout = new TableRow.LayoutParams( TableRow.LayoutParams.WrapContent, TableRow.LayoutParams.MatchParent // 高さは行に合わせる ) { Width = 0, // 幅を自動設定 RightMargin = 4, // 隙間を開ける TopMargin = 4 // 隙間を開ける }; var button = new Button(this) { Text = $"{i}-{j}", Background = Android.Graphics.Color.Blue.ToButtonPressEffect() }; row.AddView(button, buttonlayout); } } }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); //set view SetContentView(Resource.Layout.SelectView); TextView Lab_RowTitle = FindViewById<TextView>(Resource.Id.Lab_RowTitle); Lab_RowTitle.Text = "城市"; //get Data // 得到跳转到该Activity的Intent对象 Bundle bundle = Intent.GetBundleExtra("bundle"); List<string> citylist = bundle.GetStringArrayList("citylist").ToList(); //Create your application here TableLayout MainTable = FindViewById<TableLayout>(Resource.Id.table_city); Button b; TableRow tr; for (int i = 0; i < citylist.Count; i++) { tr = new TableRow(this); b = new Button(this); //string cityname = citylist[i].Substring(1, citylist[i].Length - 2); string cityname = citylist[i]; b.Text = cityname; b.Click+= delegate { CreatNewSelect(cityname); }; tr.AddView(b); MainTable.AddView(tr); } }
/// <summary> /// Create and populate UI block table based on engine data /// </summary> private void PopulateTable() { var height = _gameEngine.GetHeight(); var width = _gameEngine.GetWidth(); _blocks = new Block[width, height]; for (var row = 0; row < height; row++) { var mineRow = new TableRow(this); var mineRowParams = new TableRow.LayoutParams(TableRow.LayoutParams.MatchParent, TableRow.LayoutParams.WrapContent, 0.0f); for (var col = 0; col < width; col++) { var block = new Block(this) { Row = row, Col = col, IsFlipped = false, IsFlagged = false }; _blocks[col, row] = block; mineRow.AddView(_blocks[col, row]); } _mineTable.AddView(mineRow, mineRowParams); } }
private void UpdateTableView() { // add the strings into the table layout TableLayout table = FindViewById <TableLayout>(Resource.Id.tableLayout); var layout = new TableRow.LayoutParams( ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent); table.RemoveAllViews(); int i = 0; foreach (string s in directories) { TableRow row = new TableRow(this); TextView text = new TextView(this) { Text = s }; text.TextSize = 15; row.AddView(text); if (i++ % 2 == 0) { row.SetBackgroundColor(Android.Graphics.Color.LightBlue); } table.AddView(row); } }
private void AddTextView(string text, TextView.BufferType bufferType, TableRow tr) { TextView textView = new TextView(this); textView.SetPadding(5, 5, 5, 5); textView.SetText(text, bufferType); tr.AddView(textView); }
private TableRow textRow(string text = "") { TextView tv = newTextView(text); TableRow tr = new TableRow(this); tr.AddView(tv); return(tr); }
public AttachmentView(Context context, string title, long size) : base(context) { var row = new TableRow(context) { }; row.SetBackgroundColor(AttachmentColor); AddView(row); var tlabel = new TextView(context) { Text = title, LayoutParameters = new TableRow.LayoutParams(TableRow.LayoutParams.WrapContent, TableRow.LayoutParams.WrapContent) { LeftMargin = 4, }, }; tlabel.SetTextColor(Color.Black); tlabel.SetTextSize(ComplexUnitType.Sp, LabelTextSize); row.AddView(tlabel); if (size > 0) { var slabel = new TextView(context) { Text = FormatSize(size), LayoutParameters = new TableRow.LayoutParams(TableRow.LayoutParams.WrapContent, TableRow.LayoutParams.WrapContent) { LeftMargin = 4, RightMargin = 4, }, }; slabel.SetTextColor(Color.Black); slabel.SetTextSize(ComplexUnitType.Sp, LabelTextSize); row.AddView(slabel); } SetColumnStretchable(0, true); LayoutParameters = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WrapContent, LinearLayout.LayoutParams.WrapContent) { TopMargin = 2, }; }
/// <summary> /// Build a table row with only text views /// </summary> private TableRow BuildRow(params string[] text) { var tableRow = new TableRow(_view.Context); text.Select(x => Helpers.BuildTextView(x, _view.Context, pad: (10, 0, 10, 0))) .ToList() .ForEach(x => tableRow.AddView(x)); return(tableRow); }
void CreateGameMap() { for (var i = 0; i < Map.Height; i++) { var tableRow = new TableRow(this); for (var j = 0; j < Map.Width; j++) { if (Map.Cells[i, j] == null) { Map.Cells[i, j] = new EmptyCell(j, i); } Map.Cells[i, j].InitializeButton(this); tableRow.AddView(Map.Cells[i, j].Button); tableRow.AddView(Map.Cells[i, j].Separator); } tableLayout1.AddView(tableRow); } }
void AppendRow (TableLayout table) { TableRow row = new TableRow (this); TextView label = new TextView (this); label.SetText (Resource.String.table_layout_8_quit); label.SetPadding (3, 3, 3, 3); TextView shortcut = new TextView (this); shortcut.SetText (Resource.String.table_layout_8_ctrlq); shortcut.SetPadding (3, 3, 3, 3); shortcut.Gravity = GravityFlags.Right | GravityFlags.Top; row.AddView (label, new TableRow.LayoutParams (1)); row.AddView (shortcut, new TableRow.LayoutParams ()); table.AddView (row, new TableLayout.LayoutParams ()); }
protected override void OnCreate (Bundle savedInstanceState) { base.OnCreate (savedInstanceState); // Create your application here var container = new LinearLayout (this) { Background=Android.Graphics.Color.Yellow.ToDrawable(), }; SetContentView (container); var table = new TableLayout (this) { Background=Android.Graphics.Color.Red.ToDrawable(), StretchAllColumns=true, // カラムを均等割にする WeightSum=rows, // 行を均等割にしたいので行数を指定 }; container.AddView (table, new LinearLayout.LayoutParams ( LinearLayout.LayoutParams.MatchParent, // 幅は親に合わせる LinearLayout.LayoutParams.MatchParent) // 高さは親に合わせる ); for (int i = 0; i < rows; i++) { var rowlayouts = new TableLayout.LayoutParams ( TableLayout.LayoutParams.WrapContent, TableLayout.LayoutParams.WrapContent) { Weight = 1, // テーブルの中で均等割するので全ての重みを1にする Height=0 // 高さを自動指定 }; var row = new TableRow (this); table.AddView (row, rowlayouts); for (int j = 0; j < cols; j++) { var buttonlayout = new TableRow.LayoutParams ( TableRow.LayoutParams.WrapContent, TableRow.LayoutParams.MatchParent // 高さは行に合わせる ) { Width = 0, // 幅を自動設定 RightMargin = 4, // 隙間を開ける TopMargin = 4 // 隙間を開ける }; var button = new Button (this) { Text=$"{i}-{j}", Background=Android.Graphics.Color.Blue.ToButtonPressEffect() }; row.AddView (button, buttonlayout); } } }
private void UpdateMemoryTableUI() { tlData.RemoveAllViews(); foreach (var memoryItem in store.Items) { TableRow tr = new TableRow(this); var rowColor = Color.White; tr.SetBackgroundColor(rowColor); var cellColor = Color.Black; var txtVal1 = new TextView(this) {Text = memoryItem.Values[0]}; txtVal1.SetPadding(1, 1, 1, 1); tr.AddView(txtVal1); txtVal1.SetBackgroundColor(cellColor); var txtVal2 = new TextView(this) {Text = memoryItem.Values[1]}; txtVal2.SetPadding(1, 1, 1, 1); txtVal2.SetBackgroundColor(cellColor); tr.AddView(txtVal2); tlData.AddView(tr); } }
protected override void OnCreate(Bundle bundle) { RequestWindowFeature(WindowFeatures.NoTitle); base.OnCreate(bundle); var tableLayout = new TableLayout(this); tableLayout.LayoutParameters = new TableLayout.LayoutParams( ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent); TableRow tableRow1 = new TableRow(this); TableRow tableRow2 = new TableRow(this); var aTextView1 = new TextView(this); aTextView1.Text = "A TextView"; var aTextView2 = new TextView(this); aTextView2.Text = "And another!"; tableRow1.AddView(aTextView1, 0); tableRow1.AddView(aTextView2, 1); var aButton1 = new Button(this); aButton1.Text = "Click Me!"; var aButton2 = new Button(this); aButton2.Text = "Or Me!"; tableRow2.AddView(aButton1, 0); tableRow2.AddView(aButton2, 1); tableLayout.AddView(tableRow1, 0); tableLayout.AddView(tableRow2, 1); SetContentView(tableLayout); }
public void Refresh() { hScroll.RemoveAllViews(); var t = new TableLayout(this); foreach (Account a in Db.getAccounts()) { var tr = new TableRow(this); var b = new Button(this); b.Text = a.account_name; b.Tag = a.account_id; b.Click += Account_Click; tr.AddView(b); t.AddView(tr); } hScroll.AddView(t); }
void RefreshPharmacyTable() { pharamcyTable.Visibility = ViewStates.Visible; //Add Header Row TableRow hRow = new TableRow (this); hRow.SetBackgroundResource(Resource.Drawable.bottomline); TextView hID = GetHeadItem (ColumnPosition.cpFirst); hID.Gravity = GravityFlags.Center; hID.Text = @"ID"; hRow.AddView (hID); TextView hShortName = GetHeadItem (ColumnPosition.cpMiddle); hShortName.Gravity = GravityFlags.CenterVertical; hShortName.Text = @"Аптека"; hRow.AddView (hShortName); TextView hTradeNet = GetHeadItem (ColumnPosition.cpMiddle); hTradeNet.Gravity = GravityFlags.CenterVertical; hTradeNet.Text = @"Сеть"; hRow.AddView (hTradeNet); TextView hAddress = GetHeadItem (ColumnPosition.cpMiddle); hAddress.Gravity = GravityFlags.CenterVertical; hAddress.Text = @"Адрес"; hRow.AddView (hAddress); TextView hWeekM2 = GetHeadItem (ColumnPosition.cpMiddle); hWeekM2.Gravity = GravityFlags.CenterVertical; hWeekM2.Text = @"Неделя -2"; hRow.AddView (hWeekM2); TextView hWeekM1 = GetHeadItem (ColumnPosition.cpMiddle); hWeekM1.Gravity = GravityFlags.CenterVertical; hWeekM1.Text = @"Неделя -1"; hRow.AddView (hWeekM1); TextView hWeek = GetHeadItem (ColumnPosition.cpMiddle); hWeek.Gravity = GravityFlags.CenterVertical; hWeek.Text = @"Текущ. неделя"; hRow.AddView (hWeek); TextView hWeekP1 = GetHeadItem (ColumnPosition.cpMiddle); hWeekP1.Gravity = GravityFlags.CenterVertical; hWeekP1.Text = @"Неделя +1"; hRow.AddView (hWeekP1); TextView hWeekP2 = GetHeadItem (ColumnPosition.cpLast); hWeekP2.Gravity = GravityFlags.CenterVertical; hWeekP2.Text = @"Неделя +2"; hRow.AddView (hWeekP2); pharamcyTable.AddView(hRow); // Content if (pharamcyTable != null) { int childCount = pharamcyTable.ChildCount; // Remove all rows except the first one if (childCount > 1) { pharamcyTable.RemoveViews(1, childCount - 1); } pageNum.Text = string.Format(@"СТРАНИЦА : {0}", page); var pharmacies = (from pharm in PharmacyManager.GetPharmacies(string.Empty) orderby pharm.next, pharm.id select pharm).Skip((page - 1) * itemsNum) .Take(itemsNum); var tradenets = Common.GetTradeNets (user.username); Dictionary <int, string> tnDict = new Dictionary<int, string> (); foreach (var item in tradenets) { tnDict.Add (item.id, item.shortName); }; foreach (var pharmacy in pharmacies) { TableRow cRow = new TableRow (this); if (pharmacy.prev.Date == DateTime.Now.Date) { cRow.SetBackgroundResource (Resource.Drawable.bottomline_green); } else if (pharmacy.next.Date < DateTime.Now.Date && pharmacy.prev != DateTime.MinValue) { cRow.SetBackgroundResource (Resource.Drawable.bottomline_red); } else { cRow.SetBackgroundResource (Resource.Drawable.bottomline); } TextView id = GetItem(ColumnPosition.cpFirst); id.Gravity = GravityFlags.Center; id.Text = pharmacy.id.ToString (); cRow.AddView (id); TextView shortName = GetItem(ColumnPosition.cpMiddle); shortName.Gravity = GravityFlags.CenterVertical; shortName.Text = pharmacy.shortName; shortName.SetSingleLine (true); shortName.Ellipsize = Android.Text.TextUtils.TruncateAt.End; cRow.AddView (shortName); TextView tradeNet = GetItem(ColumnPosition.cpMiddle); tradeNet.Gravity = GravityFlags.CenterVertical; //tradeNet.Text = pharmacy.tradenet.ToString(); tradeNet.Text = tnDict[pharmacy.tradenet]; cRow.AddView (tradeNet); TextView address = GetItem(ColumnPosition.cpMiddle); address.Gravity = GravityFlags.CenterVertical; address.Text = pharmacy.address; cRow.AddView (address); DateTimeFormatInfo dfi = DateTimeFormatInfo.CurrentInfo; Calendar cal = dfi.Calendar; int dWeekM = (cal.GetWeekOfYear (pharmacy.prev, dfi.CalendarWeekRule, dfi.FirstDayOfWeek) - cal.GetWeekOfYear (DateTime.Now, dfi.CalendarWeekRule, dfi.FirstDayOfWeek)); int dWeekP = (cal.GetWeekOfYear (pharmacy.next, dfi.CalendarWeekRule, dfi.FirstDayOfWeek) - cal.GetWeekOfYear (DateTime.Now, dfi.CalendarWeekRule, dfi.FirstDayOfWeek)); TextView weekM2 = GetItem(ColumnPosition.cpMiddle); weekM2.Gravity = GravityFlags.CenterVertical; weekM2.Text = (dWeekM == -2) ? pharmacy.prev.ToString(@"d") : string.Empty; cRow.AddView (weekM2); TextView weekM1 = GetItem(ColumnPosition.cpMiddle); weekM1.Gravity = GravityFlags.CenterVertical; weekM1.Text = (dWeekM == -1) ? pharmacy.prev.ToString(@"d") : string.Empty; cRow.AddView (weekM1); // ImageView action = GetImageItem (ColumnPosition.cpMiddle); // action.SetImageResource (Resource.Drawable.ic_adjust_black_24dp); // action.SetTag (Resource.String.pharmacyID, pharmacy.id); // action.Click += Action_Click; // cRow.AddView (action); Button action = GetButtonItem (ColumnPosition.cpMiddle); action.Text = DateTime.Now.ToString (@"d"); action.SetTag (Resource.String.pharmacyID, pharmacy.id); action.Click += Action_Click; cRow.AddView (action); TextView weekP1 = GetItem(ColumnPosition.cpMiddle); weekP1.Gravity = GravityFlags.CenterVertical; weekP1.Text = (dWeekP == 1) ? pharmacy.next.ToString(@"d") : string.Empty; cRow.AddView (weekP1); TextView weekP2 = GetItem(ColumnPosition.cpLast); weekP2.Gravity = GravityFlags.CenterVertical; weekP2.Text = (dWeekP == 2) ? pharmacy.next.ToString(@"d") : string.Empty; cRow.AddView (weekP2); pharamcyTable.AddView (cRow); } } }
void RefreshTable() { table.RemoveAllViews (); TableRow header = new TableRow (Activity); header.SetMinimumHeight (70); TableRow.LayoutParams hParamsDrug = new TableRow.LayoutParams (); hParamsDrug.Height = TableLayout.LayoutParams.WrapContent; hParamsDrug.Width = TableLayout.LayoutParams.WrapContent; hParamsDrug.Gravity = GravityFlags.Center; // hParamsDrug.Span = 2; TextView hDrug = new TextView (Activity); hDrug.Text = @"Препараты"; hDrug.LayoutParameters = hParamsDrug; header.AddView(hDrug); TableRow.LayoutParams p = new TableRow.LayoutParams (); p.Height = TableLayout.LayoutParams.WrapContent; p.Width = TableLayout.LayoutParams.WrapContent; p.Gravity = GravityFlags.Center; TableLayout tlHeader = new TableLayout (Activity); TableRow rAttendance = new TableRow (Activity); foreach (var attendace in drugInfo.attendaces) { TextView hAttendace = new TextView (Activity); hAttendace.Text = attendace.date.ToString(@"dd-MMM ddd"); hAttendace.LayoutParameters = p; hAttendace.Rotation = -60; header.AddView (hAttendace); // rAttendance.AddView(hAttendace); } // tlHeader.AddView (rAttendance); // header.AddView (tlHeader); // table.AddView(header); foreach (var info in infos) { TableRow r = new TableRow (Activity); TextView v = new TextView (Activity); v.Gravity = GravityFlags.Center; v.SetSingleLine (false); v.SetMinimumHeight (72); v.SetMinimumWidth (68); v.Rotation = -90; // v.SetBackgroundResource (Resource.Style.text_row); // v.SetB // v.Text = info.infoID.ToString(); // v.Text = GetInfo(info.infoID).name; // v.SetHorizontallyScrolling (false); v.Text = info.name; v.LayoutParameters = p; r.AddView (v); TableLayout tl = new TableLayout (Activity); if (header.Parent == null) { tl.AddView (header); } tl.Id = info.id; foreach (var drug in drugs) { TableRow rr = new TableRow (Activity); rr.Id = drug.id; TextView vv = new TextView (Activity); vv.Gravity = GravityFlags.Center; vv.SetMinimumHeight (42); vv.SetMinimumWidth (76); // vv.Text = drugInfo.drugID.ToString(); // vv.Text = GetDrug(drugInfo.drugID).fullName; vv.Text = drug.fullName; vv.LayoutParameters = p; rr.AddView (vv); foreach (var attendace in drugInfo.attendaces) { RelativeLayout rl = new RelativeLayout(Activity); rl.SetGravity (GravityFlags.Center); rl.SetMinimumHeight (68); rl.SetMinimumWidth (68); rl.LayoutParameters = p; rl.Id = attendace.id; rl.Click += (object sender, EventArgs e) => { RelativeLayout rlAttendace = (RelativeLayout) sender; TableRow trDrug = (TableRow) rl.Parent; TableLayout trInfo = (TableLayout) rl.Parent.Parent; string message = string.Format(@"Click to RL.id:{0}, P,id:{1}, PP.id:{2}", rlAttendace.Id, trDrug.Id, trInfo.Id); Toast.MakeText(Activity, message, ToastLength.Short).Show(); FragmentTransaction trans = FragmentManager.BeginTransaction (); DrugInfoValueDialog drugInfoValueDialog = new DrugInfoValueDialog (); Bundle args = new Bundle(); args.PutInt(DrugInfoValueDialog.ATTENDANCE_ID, rlAttendace.Id); args.PutInt(DrugInfoValueDialog.DRUG_ID, trDrug.Id); args.PutInt(DrugInfoValueDialog.INFO_ID, trInfo.Id); // args.PutString(DrugInfoValueDialog.VALUE, GetDrugInfoValue(drugInfo.attendaces[rlAttendace.Id - 1].results, trInfo.Id, trDrug.Id)); drugInfoValueDialog.Arguments = args; drugInfoValueDialog.AfterSave += DrugInfoValueDialog_AfterSave; drugInfoValueDialog.Show (trans, "dialog fragment"); Log.Info ("ifSignInButton", "Click"); }; // string value = GetDrugInfoValue (attendace.results, info.id, drug.id); if (string.IsNullOrEmpty (value)) { ImageView iv = new ImageView (Activity); iv.SetImageResource (Resource.Drawable.ic_add_circle_white_24dp); rl.SetBackgroundColor (Android.Graphics.Color.LightPink); // rl.SetBackgroundResource(Resource.Style.alert_success); rl.AddView (iv); } else { TextView vvv = new TextView (Activity); vvv.Gravity = GravityFlags.Center; vvv.Text = value; vvv.SetTextAppearance (Activity, Resource.Style.text_success); // vvv.SetTextSize (ComplexUnitType.Sp, 24); // vvv.SetTextColor(Android.Graphics.Color.Argb); rl.SetBackgroundColor (Android.Graphics.Color.LightGreen); rl.AddView (vvv); } rr.AddView (rl); } // for (int i = 0; i < 2; i++) { // Values // ImageView iv = new ImageView (Activity); // iv.SetImageResource (Resource.Drawable.ic_add_circle_white_24dp); // rr.AddView (iv); // } tl.AddView (rr); } r.AddView (tl); table.AddView (r); } }
public Task<string> GetPasswordAsync(Stream keypadImageStream, IList<MapAreaInfo> mapAreas, SiteManager site) { var tcs = new TaskCompletionSource<string>(); var adb = new AlertDialog.Builder(Context); using (var inflater = LayoutInflater.From(adb.Context)) { var view = inflater.Inflate(Resource.Layout.XjtuCardPassword, null); var passwordView = view.FindViewById<TextView>(Resource.Id.passwordTextView); var padTable = view.FindViewById<TableLayout>(Resource.Id.passwordPadTable); var currentPassword = ""; Action updatePasswordDisplay = () => { passwordView.Text = new string('#', currentPassword.Length); }; //生成按键。 var keypadBitmap = BitmapFactory.DecodeStream(keypadImageStream); for (var row = 0; row < 4; row++) { var tr = new TableRow(adb.Context) { LayoutParameters = new ViewGroup.LayoutParams( ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent) }; padTable.AddView(tr); for (var col = 0; col < 3; col++) { var index = row * 3 + col; var indexExpr = Convert.ToString(index); View buttonView = null; if (index <= 9) { var area = mapAreas.First(a => a.Value == indexExpr); var button = new ImageButton(adb.Context) { LayoutParameters = new TableRow.LayoutParams( ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent), }; button.SetMinimumWidth(DroidUtility.DipToPixelsX(64)); button.SetMinimumHeight(DroidUtility.DipToPixelsY(64)); button.SetImageBitmap(Bitmap.CreateBitmap(keypadBitmap, area.X1, area.Y1, area.Width, area.Height)); button.SetScaleType(ImageView.ScaleType.FitCenter); button.Click += (_, e) => { currentPassword += indexExpr; updatePasswordDisplay(); }; buttonView = button; } else if (index == 10) { var button = new Button(adb.Context) { Text = "更正", LayoutParameters = new TableRow.LayoutParams( ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent) { Span = 2, Gravity = GravityFlags.CenterVertical } }; button.Click += (_, e) => { currentPassword = ""; updatePasswordDisplay(); }; buttonView = button; } if (buttonView != null) { tr.AddView(buttonView); } } } //初始化界面。 updatePasswordDisplay(); adb.SetView(view) .SetPositiveButton("确定", (_, e) => { tcs.SetResult(currentPassword); }) .SetNegativeButton("取消", (_, e) => { tcs.SetResult(null); }) .Show(); } return tcs.Task; }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Use this to return your custom view for this Fragment // return inflater.Inflate(Resource.Layout.YourFragment, container, false); layoutInflater = inflater; View rootView = inflater.Inflate(Resource.Layout.PharmacyFragment, container, false); pfSearchEdit = rootView.FindViewById<EditText> (Resource.Id.pfSearchEdit); pfSearchEdit.TextChanged += SearchEdit_TextChanged; pfPharmacyAddButton = rootView.FindViewById<Button> (Resource.Id.pfPharmacyAddButton); pfPharmacyAddButton.Click += PharmacyAddButton_Click; pfPharmacyTable = rootView.FindViewById<TableLayout> (Resource.Id.pfPharmacyTable); pfPharmacyTableHeader = rootView.FindViewById<TableLayout> (Resource.Id.pfPharmacyTableHeader); pfContent = rootView.FindViewById<LinearLayout> (Resource.Id.pfContent); // pfPharmacyTableHeaderRow = rootView.FindViewById<TableRow> (Resource.Id.pfPharmacyTableHeaderRow); pfAddPharmacy = rootView.FindViewById<TextView> (Resource.Id.pfAddPharmacy); pfAddPharmacy.Click += PharmacyAddButton_Click; //Add Header Row TableRow row = new TableRow (Activity); row.SetBackgroundResource(Resource.Drawable.bottomline); TextView id = GetHeadItem (ColumnPosition.cpFirst); id.Gravity = GravityFlags.Center; id.Text = @"ID"; row.AddView (id); TextView fullName = GetHeadItem (ColumnPosition.cpMiddle); fullName.Gravity = GravityFlags.CenterVertical; fullName.Text = @"Full Name"; row.AddView (fullName); TextView shortName = GetHeadItem (ColumnPosition.cpMiddle); shortName.Gravity = GravityFlags.CenterVertical; shortName.Text = @"Short Name"; row.AddView (shortName); TextView officialName = GetHeadItem (ColumnPosition.cpMiddle); officialName.Gravity = GravityFlags.CenterVertical; officialName.Text = @"Official Name"; row.AddView (officialName); TextView address = GetHeadItem (ColumnPosition.cpMiddle); address.Gravity = GravityFlags.CenterVertical; address.Text = @"Address"; row.AddView (address); TextView subway = GetHeadItem (ColumnPosition.cpMiddle); subway.Gravity = GravityFlags.CenterVertical; subway.Text = @"Subway"; row.AddView (subway); TextView phone = GetHeadItem (ColumnPosition.cpMiddle); phone.Gravity = GravityFlags.CenterVertical; phone.Text = @"Phone"; row.AddView (phone); TextView email = GetHeadItem (ColumnPosition.cpMiddle); email.Gravity = GravityFlags.CenterVertical; email.Text = @"E-mail"; row.AddView (email); TextView delete = GetHeadItem (ColumnPosition.cpLast); delete.Gravity = GravityFlags.CenterVertical; delete.Text = @"Actions"; row.AddView (delete); pfPharmacyTableHeader.AddView(row); //Add Header Row row2 = new TableRow (Activity); row2.SetBackgroundResource(Resource.Drawable.bottomline); TextView id2 = GetHeadItem (ColumnPosition.cpFirst); id2.Gravity = GravityFlags.Center; id2.Text = @"ID"; row2.AddView (id2); TextView fullName2 = GetHeadItem (ColumnPosition.cpMiddle); fullName2.Gravity = GravityFlags.CenterVertical; fullName2.Text = @"Full Name"; row2.AddView (fullName2); TextView shortName2 = GetHeadItem (ColumnPosition.cpMiddle); shortName2.Gravity = GravityFlags.CenterVertical; shortName2.Text = @"Short Name"; row2.AddView (shortName2); TextView officialName2 = GetHeadItem (ColumnPosition.cpMiddle); officialName2.Gravity = GravityFlags.CenterVertical; officialName2.Text = @"Official Name"; row2.AddView (officialName2); TextView address2 = GetHeadItem (ColumnPosition.cpMiddle); address2.Gravity = GravityFlags.CenterVertical; address2.Text = @"Address"; row2.AddView (address2); TextView subway2 = GetHeadItem (ColumnPosition.cpMiddle); subway2.Gravity = GravityFlags.CenterVertical; subway2.Text = @"Subway"; row2.AddView (subway2); TextView phone2 = GetHeadItem (ColumnPosition.cpMiddle); phone2.Gravity = GravityFlags.CenterVertical; phone2.Text = @"Phone"; row2.AddView (phone2); TextView email2 = GetHeadItem (ColumnPosition.cpMiddle); email2.Gravity = GravityFlags.CenterVertical; email2.Text = @"E-mail"; row2.AddView (email2); TextView delete2 = GetHeadItem (ColumnPosition.cpLast); delete2.Gravity = GravityFlags.CenterVertical; delete2.Text = @"Actions"; row2.AddView (delete2); pfPharmacyTable.AddView (row2); // // foreach (var pharmacy in pharmacies) { // TableRow row = new TableRow (this.Activity); // // TextView id = new TextView (this.Activity); // id.Text = pharmacy.id.ToString (); // row.AddView (id); // // TextView fullName = new TextView (this.Activity); // fullName.Text = pharmacy.fullName; // row.AddView (fullName); // // TextView address = new TextView (this.Activity); // address.Text = pharmacy.address; // row.AddView (address); // // pfPharmacyTable.AddView(row); // } return rootView; }
protected override void OnCreate(Bundle bundle) { base.OnCreate (bundle); // Create your application here SetContentView(Resource.Layout.TestTable); mainTable = FindViewById <TableLayout> (Resource.Id.maintable); for (int i=0; i<10 ; i++){ // Create a TableRow and give it an ID TableRow tr = new TableRow(this); tr.Id = 100+i; tr.LayoutParameters = new TableRow.LayoutParams(TableRow.LayoutParams.MatchParent, TableRow.LayoutParams.WrapContent); // Create a TextView for column 1 TextView col1 = new TextView(this); col1.Id = 200+i; col1.Text = ("col1"); col1.SetPadding(0,0,2,0); col1.SetTextColor(Android.Graphics.Color.Black); col1.LayoutParameters = new TableRow.LayoutParams(TableRow.LayoutParams.MatchParent, TableRow.LayoutParams.WrapContent); tr.AddView(col1); // Create a TextView for column 2 TextView col2 = new TextView(this); col2.Id = 300 + i; col2.Text = "col2"; col2.SetPadding(0,0,2,0); col2.SetTextColor(Android.Graphics.Color.Black); col2.LayoutParameters = new TableRow.LayoutParams(TableRow.LayoutParams.MatchParent, TableRow.LayoutParams.WrapContent); tr.AddView(col2); // Create a TextView for column 3 TextView col3 = new TextView(this); col3.Id = 500+i; col3.Text = DateTime.Now.ToString("dd.MM"); col3.SetTextColor(Android.Graphics.Color.Black); if (i%2 == 0) { col1.SetBackgroundColor(Android.Graphics.Color.White); col2.SetBackgroundColor(Android.Graphics.Color.White); col3.SetBackgroundColor(Android.Graphics.Color.White); tr.SetBackgroundColor(Android.Graphics.Color.White); } else { tr.SetBackgroundColor(Android.Graphics.Color.LightGray); col1.SetBackgroundColor(Android.Graphics.Color.LightGray); col2.SetBackgroundColor(Android.Graphics.Color.LightGray); col3.SetBackgroundColor(Android.Graphics.Color.LightGray); } col3.SetHorizontallyScrolling(false); col3.SetMaxLines(100); col3.LayoutParameters = new TableRow.LayoutParams(TableRow.LayoutParams.MatchParent, TableRow.LayoutParams.WrapContent, 1f); tr.AddView(col3); // Add the TableRow to the TableLayout mainTable.AddView(tr, new TableLayout.LayoutParams(TableLayout.LayoutParams.MatchParent, TableLayout.LayoutParams.WrapContent)); //i++; } }
private void RefreshTableContent() { if (pfPharmacyTable != null) { int childCount = pfPharmacyTable.ChildCount; // Remove all rows except the first one if (childCount > 1) { pfPharmacyTable.RemoveViews(1, childCount - 1); } pharmacies = (List<Pharmacy>)PharmacyManager.GetPharmacies (pfSearchEdit.Text, 20); foreach (var pharmacy in pharmacies) { string src = pfSearchEdit.Text; string srcWithCap = UppercaseFirst(pfSearchEdit.Text); string rpl = ""; TableRow row = new TableRow (Activity); row.SetBackgroundResource(Resource.Drawable.bottomline); TextView id = GetItem(ColumnPosition.cpFirst); id.Gravity = GravityFlags.Center; id.Text = pharmacy.id.ToString (); row.AddView (id); TextView fullName = GetItem(ColumnPosition.cpMiddle); fullName.Gravity = GravityFlags.CenterVertical; if (string.IsNullOrEmpty (src)) { fullName.Text = pharmacy.fullName; } else { rpl = pharmacy.fullName.Replace (src, @"<font color='red'>" + src + @"</font>"); rpl = rpl.Replace (srcWithCap, @"<font color='red'>" + srcWithCap + @"</font>"); fullName.TextFormatted = Html.FromHtml (rpl); } row.AddView (fullName); TextView shortName = GetItem(ColumnPosition.cpMiddle); shortName.Gravity = GravityFlags.CenterVertical; if (string.IsNullOrEmpty (src)) { shortName.Text = pharmacy.shortName; } else { rpl = pharmacy.shortName.Replace (src, @"<font color='red'>" + src + @"</font>"); rpl = rpl.Replace (srcWithCap, @"<font color='red'>" + srcWithCap + @"</font>"); shortName.TextFormatted = Html.FromHtml (rpl); } row.AddView (shortName); TextView officialName = GetItem(ColumnPosition.cpMiddle); officialName.Gravity = GravityFlags.CenterVertical; if (string.IsNullOrEmpty (src)) { officialName.Text = pharmacy.officialName; } else { rpl = pharmacy.officialName.Replace (src, @"<font color='red'>" + src + @"</font>"); rpl = rpl.Replace (srcWithCap, @"<font color='red'>" + srcWithCap + @"</font>"); officialName.TextFormatted = Html.FromHtml (rpl); } row.AddView (officialName); TextView address = GetItem(ColumnPosition.cpMiddle); address.Gravity = GravityFlags.CenterVertical; if (string.IsNullOrEmpty (src)) { address.Text = pharmacy.address; } else { rpl = pharmacy.address.Replace (src, @"<font color='red'>" + src + @"</font>"); rpl = rpl.Replace (srcWithCap, @"<font color='red'>" + srcWithCap + @"</font>"); address.TextFormatted = Html.FromHtml (rpl); } row.AddView (address); TextView subway = GetItem(ColumnPosition.cpMiddle); subway.Gravity = GravityFlags.CenterVertical; if (string.IsNullOrEmpty (src)) { subway.Text = pharmacy.subway; } else { rpl = pharmacy.subway.Replace (src, @"<font color='red'>" + src + @"</font>"); rpl = rpl.Replace (srcWithCap, @"<font color='red'>" + srcWithCap + @"</font>"); subway.TextFormatted = Html.FromHtml (rpl); } row.AddView (subway); TextView phone = GetItem(ColumnPosition.cpMiddle); phone.Gravity = GravityFlags.CenterVertical; if (string.IsNullOrEmpty (src)) { phone.Text = pharmacy.phone; } else { rpl = pharmacy.phone.Replace (src, @"<font color='red'>" + src + @"</font>"); rpl = rpl.Replace (srcWithCap, @"<font color='red'>" + srcWithCap + @"</font>"); phone.TextFormatted = Html.FromHtml (rpl); } row.AddView (phone); TextView email = GetItem(ColumnPosition.cpLast); email.Gravity = GravityFlags.CenterVertical; if (string.IsNullOrEmpty (src)) { email.Text = pharmacy.email; } else { rpl = pharmacy.email.Replace (src, @"<font color='red'>" + src + @"</font>"); rpl = rpl.Replace (srcWithCap, @"<font color='red'>" + srcWithCap + @"</font>"); email.TextFormatted = Html.FromHtml (rpl); } row.AddView (email); // Button delete = new Button (this.Activity); // delete.SetTextAppearance (this.Activity, global::Android.Resource.Style.TextAppearanceLarge); //?android:attr/textAppearanceLarge // delete.SetPadding(0, 16, 24, 16); // delete.Text = @"Del"; // delete.Id = pharmacy.id; // delete.Click += PharmacyDelete_Click; // // row.AddView (delete); pfPharmacyTable.AddView(row); } // SyncHeader (); // pfPharmacyTable.RemoveView (row2); // pfPharmacyTableHeader.AddView (row2); // pfContent.Add(row2); // pfContent.AddView(row2, 1, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent)); // ((ViewGroup) pfContent).AddView(row2, 1); //pfPharmacyTableHeaderRow = row2; } }
void BuildUI () { var hmargin = 12; var content = new LinearLayout (this) { Orientation = Orientation.Vertical, }; var scroller = new ScrollView (this) { }; scroller.AddView (content); SetContentView (scroller); // // Fields // var fields = new TableLayout (this) { LayoutParameters = new LinearLayout.LayoutParams (LinearLayout.LayoutParams.WrapContent, LinearLayout.LayoutParams.WrapContent) { TopMargin = 12, LeftMargin = hmargin, RightMargin = hmargin, }, }; fields.SetColumnStretchable (1, true); foreach (var f in state.Authenticator.Fields) { var row = new TableRow (this); var label = new TextView (this) { Text = f.Title, LayoutParameters = new TableRow.LayoutParams (LinearLayout.LayoutParams.WrapContent, LinearLayout.LayoutParams.WrapContent) { RightMargin = 6, }, }; label.SetTextSize (ComplexUnitType.Sp, 20); row.AddView (label); var editor = new EditText (this) { Hint = f.Placeholder, }; row.AddView (editor); fieldEditors [f] = editor; fields.AddView (row); } content.AddView (fields); // // Buttons // var signInLayout = new LinearLayout (this) { Orientation = Orientation.Horizontal, LayoutParameters = new LinearLayout.LayoutParams (LinearLayout.LayoutParams.FillParent, LinearLayout.LayoutParams.WrapContent) { TopMargin = 24, LeftMargin = hmargin, RightMargin = hmargin, }, }; content.AddView (signInLayout); progress = new ProgressBar (this) { Visibility = state.IsSigningIn ? ViewStates.Visible : ViewStates.Gone, Indeterminate = true, }; signInLayout.AddView (progress); signIn = new Button (this) { Text = "Sign In", LayoutParameters = new LinearLayout.LayoutParams (LinearLayout.LayoutParams.FillParent, LinearLayout.LayoutParams.WrapContent) { }, }; signIn.Click += HandleSignIn; signInLayout.AddView (signIn); if (state.Authenticator.CreateAccountLink != null) { var createAccount = new Button (this) { Text = "Create Account", LayoutParameters = new LinearLayout.LayoutParams (LinearLayout.LayoutParams.FillParent, LinearLayout.LayoutParams.WrapContent) { TopMargin = 12, LeftMargin = hmargin, RightMargin = hmargin, }, }; createAccount.Click += HandleCreateAccount; content.AddView (createAccount); } }
TableRow GetRow(string attr, string value) { TableRow row = new TableRow (this.Activity); TextView attrName = new TextView (this.Activity); // attrName.SetTextAppearance (this.Activity, global::Android.Resource.Style.TextAppearanceLarge); //?android:attr/textAppearanceLarge attrName.SetTextAppearance(Activity, Resource.Style.text_row); attrName.SetPadding(6, 6, 6, 0); attrName.Text = attr; row.AddView (attrName); TextView attrValue = new TextView (this.Activity); // attrName.SetTextAppearance (this.Activity, global::Android.Resource.Style.TextAppearanceLarge); //?android:attr/textAppearanceLarge attrValue.SetTextAppearance(Activity, Resource.Style.text_row); attrValue.SetPadding(6, 6, 6, 0); attrValue.Text = value; row.AddView (attrValue); return row; }
void RefreshTable() { table.RemoveAllViews (); TableRow header = new TableRow (Activity); header.SetMinimumHeight (88); TableRow.LayoutParams hParamsDrug = new TableRow.LayoutParams (); hParamsDrug.Height = TableLayout.LayoutParams.WrapContent; hParamsDrug.Width = TableLayout.LayoutParams.WrapContent; hParamsDrug.Gravity = GravityFlags.Center; // hParamsDrug.Span = 2; TextView hDrug = new TextView (Activity); hDrug.Text = @"Препараты"; hDrug.LayoutParameters = hParamsDrug; header.AddView(hDrug); TableRow.LayoutParams p = new TableRow.LayoutParams (); p.Height = TableLayout.LayoutParams.WrapContent; p.Width = TableLayout.LayoutParams.WrapContent; p.Gravity = GravityFlags.Center; TableLayout tlHeader = new TableLayout (Activity); TableRow rAttendance = new TableRow (Activity); foreach (var attendace in currentAttendances) { TextView hAttendace = new TextView (Activity); hAttendace.Text = attendace.date.ToString(@"dd-MMM ddd"); hAttendace.LayoutParameters = p; hAttendace.Rotation = -70; header.AddView (hAttendace); // rAttendance.AddView(hAttendace); } // tlHeader.AddView (rAttendance); // header.AddView (tlHeader); // table.AddView(header); foreach (var info in infos) { TableRow r = new TableRow (Activity); TextView v = new TextView (Activity); v.Gravity = GravityFlags.Center; v.SetSingleLine (false); v.SetMinimumHeight (72); v.SetMinimumWidth (68); v.Rotation = -90; // v.SetBackgroundResource (Resource.Style.text_row); // v.SetB // v.Text = info.infoID.ToString(); // v.Text = GetInfo(info.infoID).name; // v.SetHorizontallyScrolling (false); v.Text = info.name; v.LayoutParameters = p; r.AddView (v); TableLayout tl = new TableLayout (Activity); if (header.Parent == null) { tl.AddView (header); } tl.Id = info.id; foreach (var drug in drugs) { TableRow rr = new TableRow (Activity); rr.Id = drug.id; TextView vv = new TextView (Activity); vv.Gravity = GravityFlags.Center; vv.SetMinimumHeight (42); vv.SetMinimumWidth (76); // vv.Text = drugInfo.drugID.ToString(); // vv.Text = GetDrug(drugInfo.drugID).fullName; vv.Text = drug.fullName; vv.LayoutParameters = p; rr.AddView (vv); foreach (var attendace in currentAttendances) { RelativeLayout rl = new RelativeLayout(Activity); rl.SetGravity (GravityFlags.Center); rl.SetMinimumHeight (68); rl.SetMinimumWidth (68); rl.LayoutParameters = p; rl.Id = attendace.id; string value = string.Empty; if (attendace.id != -1) { value = AttendanceResultManager.GetAttendanceResultValue (attendace.id, info.id, drug.id); } else { value = AttendanceResultManager.GetResultValue (newAttendanceResults, info.id, drug.id); rl.Click += Rl_Click; } TextView vvv = new TextView (Activity); vvv.Gravity = GravityFlags.Center; if (string.IsNullOrEmpty (value) || value.Equals(@"N")) { vvv.SetTextAppearance (Activity, Resource.Style.text_danger); // rl.SetBa rl.SetBackgroundColor (Android.Graphics.Color.LightPink); // rl.SetBackgroundResource(Resource.Style.alert_success); } else { vvv.SetTextAppearance (Activity, Resource.Style.text_success); // vvv.SetTextSize (ComplexUnitType.Sp, 24); // vvv.SetTextColor(Android.Graphics.Color.Argb); rl.SetBackgroundColor (Android.Graphics.Color.LightGreen); } vvv.Text = AttendanceResult.StringBoolToRussian(value); rl.AddView (vvv); rr.AddView (rl); } tl.AddView (rr); } r.AddView (tl); table.AddView (r); } }
private void RefreshTableContent2() { if (pfPharmacyTable != null) { int childCount = pfPharmacyTable.ChildCount; // Remove all rows except the first one if (childCount > 1) { pfPharmacyTable.RemoveViews(1, childCount - 1); } pharmacies = (List<Pharmacy>)PharmacyManager.GetPharmacies (pfSearchEdit.Text, 20); foreach (var pharmacy in pharmacies) { string src = pfSearchEdit.Text; string srcWithCap = UppercaseFirst(pfSearchEdit.Text); string rpl = ""; TableRow row = new TableRow (Activity); row.SetBackgroundResource(Resource.Drawable.bottomline); //View view = layoutInflater.Inflate (Resource.Layout.LeftDrawerItem, null, false);//TextView id = new TextView (this.Activity); TextView id = new TextView (Activity); // id.SetTextAppearance (this.Activity, global::Android.Resource.Style.TextAppearanceLarge); //?android:attr/textAppearanceLarge // id.SetTextAppearance(Activity, Resource.Style.rowTextForPharmacy); // id.SetPadding(24, 0, 24, 0); // TableRow.LayoutParams p = // p.RightMargin = 24; // p.LeftMargin = 24; id.LayoutParameters = new TableRow.LayoutParams() {RightMargin = 24, LeftMargin = 24}; id.SetBackgroundResource(Resource.Drawable.bottomline); id.SetTextAppearance (Activity, Resource.Style.rowTextForPharmacy); id.SetHeight (48); id.Gravity = GravityFlags.Center; id.Text = pharmacy.id.ToString (); row.AddView (id); // CheckBox chk = new CheckBox (Activity); // chk.SetPadding(24, 16, 24, 16); // row.AddView (chk); TextView fullName = new TextView (Activity); // fullName.SetTextAppearance (Activity, global::Android.Resource.Style.TextAppearanceLarge); //?android:attr/textAppearanceLarge // fullName.SetPadding(0, 0, 56, 0); // TableRow.LayoutParams fullNameP = new TableRow.LayoutParams(); // fullNameP.RightMargin = 56; fullName.LayoutParameters = new TableRow.LayoutParams() {RightMargin = 56}; // fullName.SetTextAppearance (Activity, Resource.Style.rowTextForPharmacy); // fullName.SetBackgroundResource(Resource.Drawable.bottomline); fullName.SetTextAppearance (Activity, Resource.Style.rowTextForPharmacy); fullName.SetHeight (48); fullName.Gravity = GravityFlags.CenterVertical; if (string.IsNullOrEmpty (src)) { fullName.Text = pharmacy.fullName; } else { rpl = pharmacy.fullName.Replace (src, @"<font color='red'>" + src + @"</font>"); rpl = rpl.Replace (srcWithCap, @"<font color='red'>" + srcWithCap + @"</font>"); fullName.TextFormatted = Html.FromHtml (rpl); } row.AddView (fullName); TextView shortName = new TextView (Activity); // shortName.SetPadding(0, 0, 56, 0);0 // shortName.SetBackgroundResource(Resource.Drawable.bottomline); shortName.SetTextAppearance (Activity, Resource.Style.rowTextForPharmacy); shortName.SetHeight (48); shortName.Gravity = GravityFlags.CenterVertical; if (string.IsNullOrEmpty (src)) { shortName.Text = pharmacy.shortName; } else { rpl = pharmacy.shortName.Replace (src, @"<font color='red'>" + src + @"</font>"); rpl = rpl.Replace (srcWithCap, @"<font color='red'>" + srcWithCap + @"</font>"); shortName.TextFormatted = Html.FromHtml (rpl); } row.AddView (shortName); TextView officialName = new TextView (Activity); // officialName.SetPadding(0, 0, 56, 0); // officialName.SetBackgroundResource(Resource.Drawable.bottomline); officialName.SetTextAppearance (Activity, Resource.Style.rowTextForPharmacy); officialName.SetHeight (48); officialName.Gravity = GravityFlags.CenterVertical; if (string.IsNullOrEmpty (src)) { officialName.Text = pharmacy.officialName; } else { rpl = pharmacy.officialName.Replace (src, @"<font color='red'>" + src + @"</font>"); rpl = rpl.Replace (srcWithCap, @"<font color='red'>" + srcWithCap + @"</font>"); officialName.TextFormatted = Html.FromHtml (rpl); } row.AddView (officialName); TextView address = new TextView (Activity); // address.SetTextAppearance (this.Activity, global::Android.Resource.Style.TextAppearanceLarge); //?android:attr/textAppearanceLarge // address.SetPadding(0, 0, 56, 0); // address.SetTextAppearance (Activity, Resource.Style.rowTextForPharmacy); // address.SetBackgroundResource(Resource.Drawable.bottomline); address.SetTextAppearance (Activity, Resource.Style.rowTextForPharmacy); address.SetHeight (48); address.Gravity = GravityFlags.CenterVertical; if (string.IsNullOrEmpty (src)) { address.Text = pharmacy.address; } else { rpl = pharmacy.address.Replace (src, @"<font color='red'>" + src + @"</font>"); rpl = rpl.Replace (srcWithCap, @"<font color='red'>" + srcWithCap + @"</font>"); address.TextFormatted = Html.FromHtml (rpl); } row.AddView (address); TextView subway = new TextView (Activity); // subway.SetPadding(0, 0, 56, 0); // subway.SetBackgroundResource(Resource.Drawable.bottomline); subway.SetTextAppearance (Activity, Resource.Style.rowTextForPharmacy); subway.SetHeight (48); subway.Gravity = GravityFlags.CenterVertical; if (string.IsNullOrEmpty (src)) { subway.Text = pharmacy.subway; } else { rpl = pharmacy.subway.Replace (src, @"<font color='red'>" + src + @"</font>"); rpl = rpl.Replace (srcWithCap, @"<font color='red'>" + srcWithCap + @"</font>"); subway.TextFormatted = Html.FromHtml (rpl); } row.AddView (subway); TextView phone = new TextView (Activity); // phone.SetPadding(0, 0, 56, 0); // phone.SetBackgroundResource(Resource.Drawable.bottomline); phone.SetTextAppearance (Activity, Resource.Style.rowTextForPharmacy); phone.SetHeight (48); phone.Gravity = GravityFlags.CenterVertical; if (string.IsNullOrEmpty (src)) { phone.Text = pharmacy.phone; } else { rpl = pharmacy.phone.Replace (src, @"<font color='red'>" + src + @"</font>"); rpl = rpl.Replace (srcWithCap, @"<font color='red'>" + srcWithCap + @"</font>"); phone.TextFormatted = Html.FromHtml (rpl); } row.AddView (phone); TextView email = new TextView (Activity); // email.SetPadding(0, 0, 56, 0); // email.SetBackgroundResource(Resource.Drawable.bottomline); email.SetTextAppearance (Activity, Resource.Style.rowTextForPharmacy); email.SetHeight (48); email.Gravity = GravityFlags.CenterVertical; if (string.IsNullOrEmpty (src)) { email.Text = pharmacy.email; } else { rpl = pharmacy.email.Replace (src, @"<font color='red'>" + src + @"</font>"); rpl = rpl.Replace (srcWithCap, @"<font color='red'>" + srcWithCap + @"</font>"); email.TextFormatted = Html.FromHtml (rpl); } row.AddView (email); // Button delete = new Button (this.Activity); // delete.SetTextAppearance (this.Activity, global::Android.Resource.Style.TextAppearanceLarge); //?android:attr/textAppearanceLarge // delete.SetPadding(0, 16, 24, 16); // delete.Text = @"Del"; // delete.Id = pharmacy.id; // delete.Click += PharmacyDelete_Click; // // row.AddView (delete); pfPharmacyTable.AddView(row); } } }
private static TableRow CreateRow (Context context, View leftTextView, View rightTextView, GridLength leftColumnWidth, GridLength rightColumnWidth) { var tableRow = new TableRow (context); var linearLayout = new LinearLayout (context) { WeightSum = (float)1.0 }; //This is a little counter intuitive, but the Left Text View needs to be set to the Right Column Width var leftTextViewLayout = new LinearLayout.LayoutParams (ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent) { Weight = (float)rightColumnWidth.Value }; leftTextView.LayoutParameters = leftTextViewLayout; linearLayout.AddView (leftTextView); var rightTextViewLayout = new LinearLayout.LayoutParams (ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent) { Weight = (float)leftColumnWidth.Value }; rightTextView.LayoutParameters = rightTextViewLayout; linearLayout.AddView (rightTextView); tableRow.AddView (linearLayout); return tableRow; }
private View createItem(Context context, int width, Events ev) { TableRow row = new TableRow(context); row.SetVerticalGravity(GravityFlags.CenterVertical); int rowWidth = (width / 10); if (ev.IsHeader) row.AddView(createHeader(context,ev),rowWidth*10,50); else if (ev.Type == "PAA" || ev.Type == "ELASH") { row.AddView(createColumn(context, ev.Date), rowWidth * 8, 40); row.AddView(createHour(context, ev.Hour), rowWidth * 2, 40); } else { row.AddView(createDoubleColumn(context, ev.Event,ev.Date), rowWidth * 8, 80); if (ev.Type == "PREU") row.AddView(createDoubleHour(context, ev.Hour), rowWidth * 2, 80); else row.AddView(createHour(context, ev.Hour), rowWidth * 2, 80); } return row; }
TableRow GetDelim(Android.Graphics.Color color) { TableRow.LayoutParams lpDelim = new TableRow.LayoutParams (); lpDelim.Height = TableLayout.LayoutParams.WrapContent; lpDelim.Width = TableLayout.LayoutParams.WrapContent; lpDelim.SetMargins (ToDIP(2), ToDIP(1), ToDIP(2), ToDIP(1)); // lpDelim.Span = currentAttendances.Count + 2; lpDelim.Span = newAttendanceResults.Count + 2; TableRow rDelim = new TableRow (Activity); View vDelim = new View (Activity); vDelim.SetMinimumHeight (ToDIP(3)); vDelim.SetBackgroundColor (color); vDelim.LayoutParameters = lpDelim; rDelim.AddView (vDelim); return rDelim; }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.TransactionEdit); hScroll = FindViewById<LinearLayout>(Resource.Id.hScroll); txtTitle = FindViewById<EditText>(Resource.Id.txtTitle); txtTransactionDate = FindViewById<EditText>(Resource.Id.txtTransactionDate); txtTransactionDate.Click+=txtTransactionDate_Click; txtComments = FindViewById<EditText>(Resource.Id.txtComments); chkIsActive = FindViewById<CheckBox>(Resource.Id.chkIsActive); txtTotal = FindViewById<TextView>(Resource.Id.txtTotal); txtComments.SetMinWidth(WindowManager.DefaultDisplay.Width); FindViewById<Button>(Resource.Id.btnSave).Click += btnSave_Click; transaction_id = Intent.GetStringExtra("transaction_id"); if (Convert.ToString(Intent.GetStringExtra("account_id")) == "") throw new Exception("cannot create or edit a transaction without an account"); //create amount inputs var t = new TableLayout(this); t.StretchAllColumns = true; foreach (Fund f in Db.getFunds()) { var tr = new TableRow(this); var lbl = new TextView(this); lbl.Text = f.fund_name; var txt = new EditText(this); txt.SetMinWidth(50); amounts.Add(txt); txt.AfterTextChanged += Amount_Change; txt.Tag = f.fund_id; tr.AddView(lbl); tr.AddView(txt); t.AddView(tr); } hScroll.AddView(t); //load fields from database if (transaction_id == "") { account_id = Intent.GetStringExtra("account_id"); txtTransactionDate.Text=DateTime.Now.ToShortDateString(); } else { var transaction = Db.getTransaction(transaction_id); chkIsActive.Checked = transaction.is_active == "1"; txtComments.Text = transaction.transaction_comment; txtTitle.Text = transaction.transaction_title; txtTransactionDate.Text = transaction.transaction_date.ToShortDateString(); account_id = transaction.account_id; var details = Db.getTransactionDetails(transaction_id); foreach (TransactionDetail td in details) { foreach (EditText et in amounts) { if (Convert.ToString(et.Tag) == td.fund_id) et.Text = td.comment; } } } Android.Util.Log.Info("account_id", account_id); }
/// <summary> /// Create the table layout, and the image buttons, /// everything is assigned accordingly to the screen size. /// </summary> private void initializeTableLayout() { var metrics = Resources.DisplayMetrics; var widthInDp = metrics.WidthPixels; var heightInDp = metrics.HeightPixels; gameBoard = (TableLayout)FindViewById(Resource.Id.boardTable); TableRow.LayoutParams layoutParams = new TableRow.LayoutParams((widthInDp / 4), (widthInDp / 4)); TableRow tableRow1 = new TableRow(this); TableRow tableRow2 = new TableRow(this); TableRow tableRow3 = new TableRow(this); TableRow tableRow4 = new TableRow(this); bool flag = false; for (int i = 0; i < SIZE; i++) { flag = !flag; for (int j = 0; j < SIZE; j++) { gameImgButtons[i, j].SetImageResource(Resource.Drawable.blank); gameImgButtons[i, j].LayoutParameters = layoutParams; if (flag) { if ((j % 2) == 0) { gameImgButtons[i, j].SetBackgroundColor(Color.Black); } else { gameImgButtons[i, j].SetBackgroundColor(Color.Gray); } } else { if ((j % 2) != 0) { gameImgButtons[i, j].SetBackgroundColor(Color.Black); } else { gameImgButtons[i, j].SetBackgroundColor(Color.Gray); } } } tableRow1.AddView(gameImgButtons[0, i], i); tableRow2.AddView(gameImgButtons[1, i], i); tableRow3.AddView(gameImgButtons[2, i], i); tableRow4.AddView(gameImgButtons[3, i], i); } // Add rows to table gameBoard.AddView(tableRow1, 0); gameBoard.AddView(tableRow2, 1); gameBoard.AddView(tableRow3, 2); gameBoard.AddView(tableRow4, 3); }
public AttachmentView (Context context, string title, long size) : base (context) { var row = new TableRow (context) { }; row.SetBackgroundColor (AttachmentColor); AddView (row); var tlabel = new TextView (context) { Text = title, LayoutParameters = new TableRow.LayoutParams (TableRow.LayoutParams.WrapContent, TableRow.LayoutParams.WrapContent) { LeftMargin = 4, }, }; tlabel.SetTextColor (Color.Black); tlabel.SetTextSize (ComplexUnitType.Sp, LabelTextSize); row.AddView (tlabel); if (size > 0) { var slabel = new TextView (context) { Text = FormatSize (size), LayoutParameters = new TableRow.LayoutParams (TableRow.LayoutParams.WrapContent, TableRow.LayoutParams.WrapContent) { LeftMargin = 4, RightMargin = 4, }, }; slabel.SetTextColor (Color.Black); slabel.SetTextSize (ComplexUnitType.Sp, LabelTextSize); row.AddView (slabel); } SetColumnStretchable (0, true); LayoutParameters = new LinearLayout.LayoutParams (LinearLayout.LayoutParams.WrapContent, LinearLayout.LayoutParams.WrapContent) { TopMargin = 2, }; }
void RefreshTable() { table.RemoveAllViews (); TableRow.LayoutParams lpRow = new TableRow.LayoutParams (); lpRow.Height = TableLayout.LayoutParams.WrapContent; lpRow.Width = TableLayout.LayoutParams.WrapContent; lpRow.Gravity = GravityFlags.Center; //header TableRow trHeader = new TableRow (Activity); TextView tvHDrug = (TextView)layoutInflater.Inflate(Resource.Layout.DrugInfoDrugItem, null); //tvHDrug.SetTextAppearance (Activity, Resource.Style.text_header_large); tvHDrug.Text = "Препараты"; tvHDrug.LayoutParameters = lpRow; ((TableRow.LayoutParams)tvHDrug.LayoutParameters).SetMargins (0, 0, ToDIP(1) , 0); tvHDrug.SetBackgroundColor (Android.Graphics.Color.White); trHeader.AddView (tvHDrug); int i = 0; TableRow.LayoutParams lpValue = new TableRow.LayoutParams (); lpValue.Height = TableLayout.LayoutParams.WrapContent; lpValue.Width = TableLayout.LayoutParams.WrapContent; lpValue.Gravity = GravityFlags.Center; lpValue.SetMargins (ToDIP(1), ToDIP(1), ToDIP(1), ToDIP(1)); foreach (var drug in drugs) { i++; TableRow trRow = new TableRow (Activity); TextView tvDrug = (TextView)layoutInflater.Inflate(Resource.Layout.DrugInfoDrugItem, null); tvDrug.Gravity = GravityFlags.CenterVertical; tvDrug.SetTextAppearance (Activity, Resource.Style.text_row_large); tvDrug.Text = string.Format(@"{0}: {1}", i, drug.fullName); tvDrug.LayoutParameters = lpRow; tvDrug.SetBackgroundColor (Android.Graphics.Color.White); trRow.AddView (tvDrug); foreach (var info in infos) { if (trHeader.Parent == null) { TextView tvHInfo = (TextView)layoutInflater.Inflate(Resource.Layout.DrugInfoValueHeader, null); tvHInfo.Text = info.name; tvHInfo.SetBackgroundColor (Android.Graphics.Color.White); trHeader.AddView (tvHInfo); } RelativeLayout rlValue = new RelativeLayout(Activity); rlValue.SetGravity (GravityFlags.Center); rlValue.SetMinimumHeight (ToDIP(64)); rlValue.SetMinimumWidth (ToDIP(64)); rlValue.LayoutParameters = lpValue; rlValue.SetTag (Resource.String.IDinfo, info.id); rlValue.SetTag (Resource.String.IDdrug, drug.id); // rlValue.SetTag (Resource.String.IDattendance, attendace.id); string value = AttendanceResultManager.GetResultValue (newAttendanceResults, info.id, drug.id); if (info.valueType == @"number") { RelativeLayout.LayoutParams nlpValue = new RelativeLayout.LayoutParams (RelativeLayout.LayoutParams.WrapContent, RelativeLayout.LayoutParams.MatchParent); nlpValue.AddRule (LayoutRules.CenterInParent); nlpValue.SetMargins (ToDIP(1), ToDIP(1), ToDIP(1), ToDIP(1)); EditText evValue = new EditText (Activity) { LayoutParameters = nlpValue }; evValue.SetMinimumWidth (ToDIP(64)); evValue.SetMaxWidth (ToDIP(64)); evValue.InputType = Android.Text.InputTypes.ClassNumber; evValue.Text = value.Equals (@"N") ? string.Empty : value; rlValue.AddView (evValue); evValue.AfterTextChanged += NumberValue_AfterTextChanged; } if (info.valueType == @"decimal") { RelativeLayout.LayoutParams dlpValue = new RelativeLayout.LayoutParams (RelativeLayout.LayoutParams.WrapContent, RelativeLayout.LayoutParams.MatchParent); dlpValue.AddRule (LayoutRules.CenterInParent); dlpValue.SetMargins (ToDIP(1), ToDIP(1), ToDIP(1), ToDIP(1)); EditText evValue = new EditText (Activity) { LayoutParameters = dlpValue }; evValue.SetMinimumWidth (ToDIP(64)); evValue.SetMaxWidth (ToDIP(64)); evValue.InputType = Android.Text.InputTypes.NumberFlagDecimal; evValue.Text = value.Equals (@"N") ? string.Empty : value; rlValue.AddView (evValue); evValue.AfterTextChanged += DecimalValue_AfterTextChanged; } if (info.valueType == @"boolean") { rlValue.Click += Rl_Click; TextView tvValue = new TextView (Activity); tvValue.Gravity = GravityFlags.Center; if (string.IsNullOrEmpty (value) || value.Equals (@"N")) { tvValue.SetTextAppearance (Activity, Resource.Style.text_danger); rlValue.SetBackgroundColor (Android.Graphics.Color.LightPink); } else { tvValue.SetTextAppearance (Activity, Resource.Style.text_success); rlValue.SetBackgroundColor (Android.Graphics.Color.LightGreen); } tvValue.Text = AttendanceResult.StringBoolToRussian (value); rlValue.AddView (tvValue); } trRow.AddView (rlValue); } if (trHeader.Parent == null) { table.AddView (trHeader); table.AddView (GetDelim(Android.Graphics.Color.Black)); } table.AddView (trRow); table.AddView (GetDelim(Android.Graphics.Color.Brown)); } }
protected async override void OnCreate(Bundle bundle) { base.OnCreate(bundle); // Connect to the server hubConnection = new HubConnection("http://192.168.100.3:4000/"); // Create a proxy to the 'IOTHub' SignalR Hub chatHubProxy = hubConnection.CreateHubProxy("IOTHub"); // Start the connection await hubConnection.Start(); chatHubProxy.On<List<IOTDevice>>("UpdateState", nodes => { var Msg = string.Empty; foreach (var item in nodes) { Msg += item.ID + " = " + item.State+", "; } Toast.MakeText(this, Msg, ToastLength.Short).Show(); }); hubConnection.ConnectionSlow += () => { Toast.MakeText(this, "Connection problems.\r\n",ToastLength.Short).Show(); }; hubConnection.Error += ex => { Toast.MakeText(this, string.Format("SignalR error: {0}\r\n", ex.Message), ToastLength.Short).Show(); }; // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); TableLayout _table = (TableLayout)FindViewById(Resource.Id.table); var layoutParams = new TableRow.LayoutParams( ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent); // create buttons in a loop for (int i = 0; i < 27; i++) { TableRow tableRow = new TableRow(this); TextView Lbl = new TextView(this); Lbl.Text = "PIN - "+i; Button button = new Button(this); Button button2 = new Button(this); button.Text = "Turn Pin " + i + " ON"; button2.Text = "Turn Pin " + i + " OFF"; button.Tag = "ON:"+i; button2.Tag = "OFF:" + i; // R.id won't be generated for us, so we need to create one //button.Id = i; button.Click += Button_Click; button2.Click += Button_Click; button.LayoutParameters = layoutParams; button2.LayoutParameters = layoutParams; tableRow.AddView(Lbl, 0); tableRow.AddView(button, 1); tableRow.AddView(button2, 2); _table.AddView(tableRow, 0); } }
private void PreparePage() { //status = DialogManager.ShowStatus(this, Database.GetText("Communicating", "System")); Core.LiveDataVector vec = Manager.LiveDataVector; vec.DeployEnabledIndex(); vec.DeployShowedIndex(); RunOnUiThread(() => { for (int i = 0; i < vec.ShowedCount; i++) { TextView content = new TextView(this); content.Text = StaticString.beforeBlank + vec[vec.ShowedIndex(i)].Content; TextView unit = new TextView(this); unit.Text = vec[vec.ShowedIndex(i)].Unit; TextView value = new TextView(this); value.Text = vec[vec.ShowedIndex(i)].Value; value.SetTextColor(Android.Graphics.Color.DarkBlue); TableRow row = new TableRow(this); row.AddView(content); row.AddView(value); row.AddView(unit); layout.AddView(row); vec[vec.ShowedIndex(i)].PropertyChanged += (sender, e) => { if (e.PropertyName == "Value") { OnValueChange((Core.LiveData)sender); } }; } status.Dismiss(); }); }