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


C# Context.GetString方法代码示例

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


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

示例1: GetViewForDoorHandle

        private static View GetViewForDoorHandle(Context context, HomeMaticChannel channel)
        {
            var view = LayoutInflater.From(context).Inflate(Resource.Layout.DoorHandle, null);
            var state = (channel as DoorHandle).State;

            switch (state)
            {
                case DoorHandleState.Open:
                    view.FindViewById<TextView>(Resource.Id.tvState).Text = context.GetString(Resource.String.open);
                    view.FindViewById<ImageView>(Resource.Id.ivOpen).Visibility = ViewStates.Visible;
                    view.FindViewById<ImageView>(Resource.Id.ivClosed).Visibility = ViewStates.Gone;
                    break;
                case DoorHandleState.Tilted:
                    view.FindViewById<TextView>(Resource.Id.tvState).Text = context.GetString(Resource.String.tilted);
                    view.FindViewById<ImageView>(Resource.Id.ivOpen).Visibility = ViewStates.Visible;
                    view.FindViewById<ImageView>(Resource.Id.ivClosed).Visibility = ViewStates.Gone;
                    break;
                case DoorHandleState.Closed:
                    view.FindViewById<TextView>(Resource.Id.tvState).Text = context.GetString(Resource.String.closed);
                    view.FindViewById<ImageView>(Resource.Id.ivOpen).Visibility = ViewStates.Gone;
                    view.FindViewById<ImageView>(Resource.Id.ivClosed).Visibility = ViewStates.Visible;
                    break;
            }

            return view;
        }
开发者ID:Thepagedot,项目名称:Rhome-App,代码行数:26,代码来源:HomeMaticLayout.cs

示例2: IsMetric

        /// <summary>
        /// Determines whether the specified context is metric.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <returns></returns>
        public static bool IsMetric(Context context)
        {
            // get the location and units preferences for this data
            var prefs = PreferenceManager.GetDefaultSharedPreferences(context);
            var units = prefs.GetString(context.GetString(Resource.String.TempPrefKey), context.GetString(Resource.String.LocationPrefDefault));

            return units.Equals(context.GetString(Resource.String.TempPrefMetric));
        }
开发者ID:chadsmith12,项目名称:Spring-Time,代码行数:13,代码来源:Converter.cs

示例3: StringResource

        public StringResource(Context context)
        {
            _dictionary = new Dictionary<string, string> ();

            _dictionary.Add ("subject", context.GetString(Resource.String.subject));
            _dictionary.Add ("message_frontend", context.GetString(Resource.String.message_frontend));
            _dictionary.Add ("message_backend", context.GetString(Resource.String.message_backend));
            _dictionary.Add ("message_mobile", context.GetString(Resource.String.message_mobile));
            _dictionary.Add ("message_generic", context.GetString(Resource.String.message_generic));
        }
开发者ID:bernardo-bruning,项目名称:AnalysiSkill,代码行数:10,代码来源:StringResource.cs

示例4: HSVColorPickerDialog

        public HSVColorPickerDialog(Context context, Color initialColor, Action<Color> listener)
            : base(context)
        {
            this.selectedColor = initialColor;
            this.listener = listener;

            colorWheel = new HSVColorWheel(context);
            valueSlider = new HSVValueSlider(context);
            var padding = (int)(context.Resources.DisplayMetrics.Density * PADDING_DP);
            var borderSize = (int)(context.Resources.DisplayMetrics.Density * BORDER_DP);
            var layout = new RelativeLayout(context);

            var lp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MatchParent, RelativeLayout.LayoutParams.MatchParent);
            lp.BottomMargin = (int)(context.Resources.DisplayMetrics.Density * CONTROL_SPACING_DP);
            colorWheel.setListener((color) => valueSlider.SetColor(color, true));
            colorWheel.setColor(initialColor);
            colorWheel.Id = (1);
            layout.AddView(colorWheel, lp);

            int selectedColorHeight = (int)(context.Resources.DisplayMetrics.Density * SELECTED_COLOR_HEIGHT_DP);

            var valueSliderBorder = new FrameLayout(context);
            valueSliderBorder.SetBackgroundColor(BORDER_COLOR);
            valueSliderBorder.SetPadding(borderSize, borderSize, borderSize, borderSize);
            valueSliderBorder.Id = (2);
            lp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MatchParent, selectedColorHeight + 2 * borderSize);
            lp.BottomMargin = (int)(context.Resources.DisplayMetrics.Density * CONTROL_SPACING_DP);
            lp.AddRule(LayoutRules.Below, 1);
            layout.AddView(valueSliderBorder, lp);

            valueSlider.SetColor(initialColor, false);
            valueSlider.SetListener((color) =>
            {
                selectedColor = color;
                selectedColorView.SetBackgroundColor(color);
            });
            valueSliderBorder.AddView(valueSlider);

            var selectedColorborder = new FrameLayout(context);
            selectedColorborder.SetBackgroundColor(BORDER_COLOR);
            lp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MatchParent, selectedColorHeight + 2 * borderSize);
            selectedColorborder.SetPadding(borderSize, borderSize, borderSize, borderSize);
            lp.AddRule(LayoutRules.Below, 2);
            layout.AddView(selectedColorborder, lp);

            selectedColorView = new View(context);
            selectedColorView.SetBackgroundColor(selectedColor);
            selectedColorborder.AddView(selectedColorView);

            SetButton((int)DialogButtonType.Negative, context.GetString(Android.Resource.String.Cancel), ClickListener);
            SetButton((int)DialogButtonType.Positive, context.GetString(Android.Resource.String.Ok), ClickListener);

            SetView(layout, padding, padding, padding, padding);
        }
开发者ID:mattleibow,项目名称:shopify-bindings,代码行数:54,代码来源:HSVColorPickerDialog.cs

示例5: SelectTypeface

 //returns correct Typeface from fontName
 public static Typeface SelectTypeface(Context context, String fontName)
 {
     if (fontName.Equals (context.GetString (Resource.String.Verveine)))
         return Typeface.CreateFromAsset (context.Assets, "fonts/Verveine W01 Regular.ttf");
     else if (fontName.Equals (context.GetString (Resource.String.DIN_light)))
         return Typeface.CreateFromAsset (context.Assets, "fonts/DINPro-Light.ttf");
     else if (fontName.Equals (context.GetString (Resource.String.DIN_regular)))
         return Typeface.CreateFromAsset (context.Assets, "fonts/DINPro-Regular.ttf");
     else if (fontName.Equals (context.GetString (Resource.String.Sketchblock)))
         return Typeface.CreateFromAsset (context.Assets, "fonts/sketch_block_light.ttf");
     else
         return null;
 }
开发者ID:FrederickEskens,项目名称:Totem,代码行数:14,代码来源:CustomFontHelper.cs

示例6: onSelectImageOk

		public static void onSelectImageOk(Context context, UploadPhoto uploadPhoto, PopupNoticeInfomation popupNotice,  int requestCode, Result resultCode, Intent data, Guid bookingId, bool isInConference){				
			if (data == null) {
				try{
					Intent mediaScanIntent = new Intent (Intent.ActionMediaScannerScanFile);
					Uri contentUri = Uri.FromFile (App._file);
					mediaScanIntent.SetData (contentUri);
					//SendBroadcast (mediaScanIntent);
					uploadPhoto.onResultChoosed (contentUri, isInConference, bookingId);
				} catch(Exception e){
					Console.Write (e.Message);
					popupNotice.showNoticeDialog (context.GetString(Resource.String.title_notice), context.GetString(Resource.String.get_img_from_lib));
				}
			} else {
				uploadPhoto.onResultChoosed (data, isInConference, bookingId);
			}
		}
开发者ID:borain89vn,项目名称:demo2,代码行数:16,代码来源:utilsAndroid.cs

示例7: PlaySound

        /// <summary>
        /// Plaies a sound from an Assets sound file
        /// </summary>
        /// <param name="context">Context.</param>
        /// <param name="fileName">File name.</param>
        /// <param name = "folderName">Folder Name. Takes "Sounds" if nothing else is set</param>
        public static void PlaySound(Context context, string fileName, string folderName = null)
        {
            // Set default folder "Sounds" if nothing else is set
            if (folderName == null)
                folderName = "Sounds";

            try
            {
                // Describe sound file from Assets properly
                var descriptor = context.Assets.OpenFd(folderName + "/" +  fileName);

                // Reset player if still playing
                Stop();

                // Play sound file
                player.SetDataSource(descriptor.FileDescriptor, descriptor.StartOffset, descriptor.Length);
                player.Prepare();
                player.Start();
            }
            catch (FileNotFoundException)
            {
                Toast.MakeText(context, context.GetString(Resource.String.error_soundfileNotFound), ToastLength.Short);
                System.Console.WriteLine("Error: Soundfile '" + fileName + "' could not be found.");
            }
        }
开发者ID:fawuser,项目名称:IRMGARD,代码行数:31,代码来源:SoundPlayer.cs

示例8: OnReceive

		public override void OnReceive (Context context, Intent intent)
		{
			// Create deep link intent with correct action and add play store referral information
			var deepLinkIntent = AppInviteReferral.AddPlayStoreReferrerToIntent(intent,
				new Intent(context.GetString(Resource.String.action_deep_link)));

			// Let any listeners know about the change
			LocalBroadcastManager.GetInstance(context).SendBroadcast(deepLinkIntent);
		}
开发者ID:RobGibbens,项目名称:Coffee-Filter,代码行数:9,代码来源:ReferrerReceiver.cs

示例9: LocalizationService

 public LocalizationService(Context context, Type stringType)
 {
     _strings = stringType.GetRuntimeFields()
                         .Where(field => field.IsLiteral)
                         .ToDictionary(
                             field => field.Name,
                             field => context.GetString((int)field.GetRawConstantValue())
                         );
 }
开发者ID:snipervld,项目名称:StormXamarin,代码行数:9,代码来源:LocalizationService.cs

示例10: StartMap

        public static void StartMap(Context context)
        {
            var locationIntent = new Intent(Intent.ActionView);
            var prefs = PreferenceManager.GetDefaultSharedPreferences(context);
            var location = prefs.GetString(context.GetString(Resource.String.LocationPrefKey), context.GetString(Resource.String.LocationPrefDefault));

            var geoLocation = Uri.Parse("geo:0,0?").BuildUpon().AppendQueryParameter("q", location).Build();
            locationIntent.SetData(geoLocation);

            if (locationIntent.ResolveActivity(context.PackageManager) != null)
            {
                context.StartActivity(locationIntent);
            }
            else
            {
                Log.Debug("SpringTime", "Could not open activity with location: " + location);
            }
        }
开发者ID:chadsmith12,项目名称:Spring-Time,代码行数:18,代码来源:Intents.cs

示例11: NumberPickerPreference

        public NumberPickerPreference(Context context, IAttributeSet attrs) : base (context, attrs)
        {
            DialogLayoutResource = (BuildVersionCodes.Honeycomb > Build.VERSION.SdkInt) ? Resource.Layout.RadioGroupDialog : Resource.Layout.NumberPickerDialog;            

            SetPositiveButtonText(Android.Resource.String.Ok);
            SetNegativeButtonText(Android.Resource.String.Cancel);

            int value = PreferenceManager.GetDefaultSharedPreferences(Context).GetInt(SettingsScreen.DefaultRadiusKey, SettingsScreen.DefaultRadiusValue);
            Summary = string.Format(context.GetString(Resource.String.settings_default_radius_sum), value);
        }
开发者ID:foxanna,项目名称:SimpleLocationAlarm,代码行数:10,代码来源:NumberPickerPreference.cs

示例12: FormatSessionSubtitle

		/**
	     * Format and return the given {@link Blocks} and {@link Rooms} values using
	     * {@link #CONFERENCE_TIME_ZONE}.
	     */
		public static string FormatSessionSubtitle (long blockStart, long blockEnd, String roomName, Context context)
		{
			Java.Util.TimeZone.Default = ConferenceTimeZone;
	
			// NOTE: There is an efficient version of formatDateRange in Eclair and
			// beyond that allows you to recycle a StringBuilder.
			string timeString = DateUtils.FormatDateRange (context, blockStart, blockEnd, TIME_FLAGS);
	
			return context.GetString (Resource.String.session_subtitle, timeString, roomName);
		}
开发者ID:CHANDAN145,项目名称:monodroid-samples,代码行数:14,代码来源:UIUtils.cs

示例13: formatTemperature

 public static String formatTemperature(Context context, double temperature, bool isMetric)
 {
     double temp;
     if (!isMetric) {
         temp = 9 * temperature / 5 + 32;
     } else {
         temp = temperature;
     }
     return String.Format (context.GetString (Resource.String.format_temperature), temp);
 }
开发者ID:Screech129,项目名称:WeatherApp,代码行数:10,代码来源:Utility.cs

示例14: ShowSimpleDialog

    public static void ShowSimpleDialog(Context context, string title, string message)
    {
      AlertDialog.Builder builder = new AlertDialog.Builder(context);
      builder.SetTitle(title);
      builder.SetMessage(message);

      AlertDialog dialog = builder.Create();
      dialog.SetButton(context.GetString(Resource.String.text_button_ok),
        (sender, args) => dialog.Dismiss());
      dialog.Show();
    }
开发者ID:amatkivskiy,项目名称:sitecore-xamarin-pcl-sdk,代码行数:11,代码来源:DialogHelper.cs

示例15: FormatAddress

        /**
     * Formats the address for display.
     *
     * @param context The context to get String resources from.
     * @param address The {@link Address} to format.
     * @return The address in a format suitable for display to the user.
     */
        public static string FormatAddress (Context context, Address address) 
        {
            // different locales may need different address formats, which would be handled in
            // R.string.address_format
            var address2 = string.IsNullOrEmpty (address.Address2) ? address.Address2 : address.Address2 + "\n";
            var address3 = string.IsNullOrEmpty (address.Address3) ? address.Address3 : address.Address3 + "\n";


            return context.GetString (Resource.String.address_format, address.Name,
                                    address.Address1, address2, address3, address.City, address.State, address.PostalCode);
        }
开发者ID:apcurium,项目名称:xamarin-bindings,代码行数:18,代码来源:Util.cs


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