当前位置: 首页>>代码示例>>C#>>正文


C# TableRow.SetBackgroundResource方法代码示例

本文整理汇总了C#中TableRow.SetBackgroundResource方法的典型用法代码示例。如果您正苦于以下问题:C# TableRow.SetBackgroundResource方法的具体用法?C# TableRow.SetBackgroundResource怎么用?C# TableRow.SetBackgroundResource使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TableRow的用法示例。


在下文中一共展示了TableRow.SetBackgroundResource方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: OnCreateView

        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);
//.........这里部分代码省略.........
开发者ID:pafik13,项目名称:pharm-merch-tablet,代码行数:101,代码来源:PharmacyFragment.cs

示例2: RefreshTableContent

        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);
                    }
//.........这里部分代码省略.........
开发者ID:pafik13,项目名称:pharm-merch-tablet,代码行数:101,代码来源:PharmacyFragment.cs

示例3: RefreshTableContent2

        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)) {
//.........这里部分代码省略.........
开发者ID:pafik13,项目名称:pharm-merch-tablet,代码行数:101,代码来源:PharmacyFragment.cs

示例4: RefreshPharmacyTable

        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;
//.........这里部分代码省略.........
开发者ID:pafik13,项目名称:SBL-CRM,代码行数:101,代码来源:MainActivity.cs


注:本文中的TableRow.SetBackgroundResource方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。