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


C# Spinner.SetBackgroundResource方法代码示例

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


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

示例1: OnCreate

        protected override void OnCreate (Bundle bundle)
        {
            base.OnCreate (bundle);

            // Create your application here
            // Set the layout
            SetContentView(Resource.Layout.ActivitySettings);
            _OfflineSwitch = FindViewById<Switch> (Resource.Id.switch1);
            _btnUploadData = FindViewById<Button>(Resource.Id.BtnUploadData);
            _btnClear = FindViewById<Button>(Resource.Id.BtnClear);
            _btnUrlSave = FindViewById<Button>(Resource.Id.BtnUrlSave);
            _btnChangePassword = FindViewById<Button>(Resource.Id.BtnChangePassword);
            _btnLog = FindViewById<Button>(Resource.Id.BtnLog);
            _edUrl = FindViewById<EditText>(Resource.Id.edUrl);
            _tvAndroidID = FindViewById<TextView>(Resource.Id.tvAndroidID);

            // Spinner for the main color of the app
            // Set the main colors
            _colors = new List<int>();
            _colors.Add(Android.Resource.Color.HoloOrangeDark);
            _colors.Add(Android.Resource.Color.HoloBlueDark);
            _colors.Add(Android.Resource.Color.DarkerGray);
            _colors.Add(Android.Resource.Color.HoloGreenDark);
            _colors.Add(Android.Resource.Color.HoloRedDark);

            // Initialze the color spinner
            _spinnerMainColor = FindViewById<Spinner>(Resource.Id.spinnerMainColor);
            MainColorViewAdapter _adapter = new MainColorViewAdapter (this,_colors);
            _spinnerMainColor.SetBackgroundColor( Resources.GetColor(DataAccessLayer.Utilities.MainColor));
            _spinnerMainColor.SetBackgroundResource(DataAccessLayer.Utilities.MainColor);
            _spinnerMainColor.Adapter = _adapter;

            // Initialize the LoginSaveOption Spinner
            _spinnerLoginSaveOption = FindViewById<Spinner>(Resource.Id.spinnerLoginSaveOption);
            LoginSaveOptionViewAdapter _LSO_adapter = new LoginSaveOptionViewAdapter(this);



            _spinnerLoginSaveOption.Adapter = _LSO_adapter;

            // Set the right selected item for the spinnerMainColor
            switch (DataAccessLayer.Utilities.MainColor)
            {
                case Android.Resource.Color.HoloOrangeDark:
                    _spinnerMainColor.SetSelection(0);
                    break;
                case Android.Resource.Color.HoloBlueDark:
                    _spinnerMainColor.SetSelection(1);
                    break;
                case Android.Resource.Color.DarkerGray:
                    _spinnerMainColor.SetSelection(2);
                    break;
                case Android.Resource.Color.HoloGreenDark:
                    _spinnerMainColor.SetSelection(3);
                    break;
                case Android.Resource.Color.HoloRedDark:
                    _spinnerMainColor.SetSelection(4);
                    break;
                default:
                    _spinnerMainColor.SetSelection(0);
                    break;
            }

            // Set the right selected item for the spinnerLoginSaveOption
            _spinnerLoginSaveOption.SetSelection(Convert.ToInt32( BusinessLayer.User.GetLoginSaveOption()));

            // Set the status of the button 
            if (UI.MainActivity.User.NetworkStatus == DataAccessLayer.NetworkState.Disconnected) 
                _OfflineSwitch.Checked = false;
            else
                _OfflineSwitch.Checked = true;

            // Enable or disable the Button to sync offline data
            offlineTasks =  BusinessLayer.Task.HasNewOfflineTasks();
            if (offlineTasks != 0 &&MainActivity.User.NetworkStatus  != DataAccessLayer.NetworkState.Disconnected)
                _btnUploadData.Enabled = true;
            else
                _btnUploadData.Enabled = false;

            // If the app is offline, the switch control must be disabled
            if (UI.MainActivity._networkstate == DataAccessLayer.NetworkState.Disconnected)
                _OfflineSwitch.Enabled = false;
            else
                _OfflineSwitch.Enabled = true;

            // Set the current URL
            _edUrl.Text = DataAccessLayer.Utilities.ServerIP;

            // set the android ID
            _tvAndroidID.Text = Android.Provider.Settings.Secure.GetString(this.ContentResolver,
                Android.Provider.Settings.Secure.AndroidId); 
            
            // Set the event handler of the controls 
            SetControlEvents(true);

        }
开发者ID:MbProg,项目名称:TestApolloAndroid,代码行数:96,代码来源:SettingsActivity.cs


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