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


C# Context.GetActivity方法代码示例

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


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

示例1: ItemsSourceAdapter

 /// <summary>
 ///     Initializes a new instance of the <see cref="ItemsSourceAdapter" /> class.
 /// </summary>
 public ItemsSourceAdapter([NotNull] object container, Context context, bool listenCollectionChanges, string dropDownItemTemplateSelectorName = null,
     string itemTemplateSelectorName = AttachedMemberConstants.ItemTemplateSelector, string dropDownItemTemplateIdName = null,
     string itemTemplateIdName = AttachedMemberConstants.ItemTemplate)
 {
     Should.NotBeNull(container, "container");
     _container = container;
     _itemTemplateProvider = new DataTemplateProvider(container, itemTemplateIdName, itemTemplateSelectorName);
     _dropDownTemplateProvider = new DataTemplateProvider(container,
         dropDownItemTemplateIdName ?? AttachedMembers.AdapterView.DropDownItemTemplate,
         dropDownItemTemplateSelectorName ?? AttachedMembers.AdapterView.DropDownItemTemplateSelector);
     _layoutInflater = context.GetBindableLayoutInflater();
     if (listenCollectionChanges)
         _weakHandler = ReflectionExtensions.MakeWeakCollectionChangedHandler(this, (adapter, o, arg3) => adapter.OnCollectionChanged(o, arg3));
     var activityView = context.GetActivity() as IActivityView;
     if (activityView != null)
     {
         _listener = ReflectionExtensions.CreateWeakEventHandler<ItemsSourceAdapter, EventArgs>(this, (adapter, o, arg3) => adapter.ActivityViewOnDestroyed((Activity)o));
         activityView.Mediator.Destroyed += _listener.Handle;
     }
 }
开发者ID:MuffPotter,项目名称:MugenMvvmToolkit,代码行数:23,代码来源:ItemsSourceAdapter.cs

示例2: ItemsSourceAdapter

 public ItemsSourceAdapter([NotNull] object container, Context context, bool listenCollectionChanges, string dropDownItemTemplateSelectorName = null,
     string itemTemplateSelectorName = null, string dropDownItemTemplateName = null, string itemTemplateName = null)
 {
     Should.NotBeNull(container, "container");
     _container = container;
     container.TryGetBindingMemberValue(AttachedMembers.Object.StableIdProvider, out _stableIdProvider);
     _itemTemplateProvider = new DataTemplateProvider(container, itemTemplateName ?? AttachedMemberConstants.ItemTemplate,
         itemTemplateSelectorName ?? AttachedMemberConstants.ItemTemplateSelector);
     _dropDownTemplateProvider = new DataTemplateProvider(container,
         dropDownItemTemplateName ?? AttachedMembers.AdapterView.DropDownItemTemplate,
         dropDownItemTemplateSelectorName ?? AttachedMembers.AdapterView.DropDownItemTemplateSelector);
     _layoutInflater = context.GetBindableLayoutInflater();
     if (listenCollectionChanges)
         _weakHandler = ReflectionExtensions.MakeWeakCollectionChangedHandler(this, (adapter, o, arg3) => adapter.OnCollectionChanged(o, arg3));
     var activityView = context.GetActivity() as IActivityView;
     if (activityView != null)
     {
         _listener = ReflectionExtensions.CreateWeakEventHandler<ItemsSourceAdapter, EventArgs>(this, (adapter, o, arg3) => adapter.ActivityViewOnDestroyed((Activity)o));
         activityView.Mediator.Destroyed += _listener.Handle;
     }
     _defaultDropDownTemplate = IsSpinner()
         ? global::Android.Resource.Layout.SimpleDropDownItem1Line
         : global::Android.Resource.Layout.SimpleSpinnerDropDownItem;
     var absListView = container as AdapterView;
     if (absListView != null)
     {
         var member = BindingServiceProvider.MemberProvider.GetBindingMember(absListView.GetType(), AttachedMembers.ViewGroup.DisableHierarchyListener, false, false);
         if (member.CanWrite)
             member.SetSingleValue(absListView, Empty.TrueObject);
     }
 }
开发者ID:sami1971,项目名称:MugenMvvmToolkit,代码行数:31,代码来源:ItemsSourceAdapter.cs

示例3: SetListener

 public void SetListener(Context context, DrawerLayout.IDrawerListener listener)
 {
     _listener = listener;
     if (!(listener is ActionBarDrawerToggle))
         return;
     var activity = context.GetActivity() as IActivityView;
     if (activity == null)
         return;
     activity.Mediator.OptionsItemSelected += OptionsItemSelected;
     activity.Mediator.ConfigurationChanged += OnConfigurationChanged;
     activity.Mediator.PostCreate += OnPostCreate;
 }
开发者ID:dbeattie71,项目名称:MugenMvvmToolkit,代码行数:12,代码来源:AppCompatModule.cs

示例4: StartActivity

 protected virtual void StartActivity(Context context, Intent intent, IDataContext dataContext)
 {
     var activity = context.GetActivity();
     Action<Context, Intent, IDataContext> startAction = null;
     if (activity != null)
         startAction = activity.GetBindingMemberValue(AttachedMembers.Activity.StartActivityDelegate);
     if (startAction == null)
         context.StartActivity(intent);
     else
         startAction(context, intent, dataContext);
 }
开发者ID:sami1971,项目名称:MugenMvvmToolkit,代码行数:11,代码来源:NavigationService.cs

示例5: TryListenActivity

 protected void TryListenActivity(Context context)
 {
     var activity = context.GetActivity();
     var activityView = activity as IActivityView;
     if (activityView == null)
         Tracer.Warn("{0} - The type {1} does not implement the IActivityView.", this, context);
     else
     {
         InitializeListener();
         activityView.Mediator.Destroyed += _listener.Handle;
     }
 }
开发者ID:FilipHerman,项目名称:MugenMvvmToolkit,代码行数:12,代码来源:ItemsSourceGeneratorBase.cs


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