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


C# Activity.SetContentView方法代码示例

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


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

示例1: MainActivityBinding

        private MainActivityBinding(Activity activity, int layoutId)
        {
            activity.SetContentView(layoutId);
            toolbar = activity.FindViewById<Toolbar>(Resource.Id.toolbar);
            drawer  = activity.FindViewById<DrawerLayout>(Resource.Id.drawer);
            navView = activity.FindViewById<NavigationView>(Resource.Id.nav_view);

            var decorView = activity.Window.DecorView;
            Root = (ViewGroup) decorView.FindViewById(global::Android.Resource.Id.Content);
        }
开发者ID:nepula-h-okuyama,项目名称:DroidKaigi2016Xamarin,代码行数:10,代码来源:MainActivityBinding.cs

示例2: WebViewActivityBinding

        private WebViewActivityBinding(Activity activity, int layoutId)
        {
            activity.SetContentView(layoutId);

            webview = activity.FindViewById<WebView>(Resource.Id.webview);
            toolbar = activity.FindViewById<Toolbar>(Resource.Id.toolbar);

            var decorView = activity.Window.DecorView;
            Root = (ViewGroup) decorView.FindViewById(global::Android.Resource.Id.Content);
        }
开发者ID:amay077,项目名称:DroidKaigi2016Xamarin,代码行数:10,代码来源:WebViewActivityBinding.cs

示例3: Bind

        public void Bind(Activity activity)
        {
            if (activity == null)
                throw new ArgumentNullException();

            activity.SetContentView(ResourceId);

            if (BindOutlets)
            {
                FieldInfo[] fields = activity.GetType().GetFields(BindingFlags.NonPublic | BindingFlags.Instance);
                foreach (FieldInfo field in fields)
                {
                    object[] outlets = field.GetCustomAttributes(typeof(OutletAttribute), false);
                    if (outlets.Length == 0)
                        continue;

                    OutletAttribute outlet = (OutletAttribute) outlets[0];
                    field.SetValue(activity, activity.FindViewById(outlet.ResourceId));
                }
            }

            if (BindActions)
            {
                MethodInfo[] methods = activity.GetType().GetMethods(BindingFlags.NonPublic | BindingFlags.Instance);
                foreach (MethodInfo method in methods)
                {
                    object[] actions = method.GetCustomAttributes(typeof(ActionAttribute), false);
                    if (actions.Length == 0)
                        continue;

                    foreach (ActionAttribute action in actions)
                    {
                        try
                        {
                            FieldInfo field = activity.GetType().GetField(action.Field, BindingFlags.NonPublic | BindingFlags.Instance);
                            if (field == null)
                                throw new Exception();

                            EventInfo handler = field.FieldType.GetEvent(action.Handler, BindingFlags.Public | BindingFlags.Instance);
                            if (handler == null)
                                throw new Exception();

                            handler.AddEventHandler(field.GetValue(activity), Delegate.CreateDelegate(handler.EventHandlerType, activity, method));
                        }
                        catch
                        {
                            Console.WriteLine("Can't bind {0}.{1} with {2}", action.Field, action.Handler, method.Name);
                            continue;
                        }
                    }
                }
            }
        }
开发者ID:vitaly-maximov,项目名称:Mono-for-Android-Binder,代码行数:53,代码来源:BinderAttribute.cs

示例4: AndroidDevice

        public AndroidDevice(Activity activity, ConnectionType connectionType, string connectionString)
            : base(connectionType, connectionString, new JsonProvider())
        {
            // Setup the WebView/Browser
            _activity = activity;
            Browser = new AndroidBrowser(new WebView(activity));
            _activity.SetContentView(WebView);

            // Populate device info
            Wifi = (WifiManager)activity.GetSystemService(Context.WifiService);
            DeviceInfo = new DeviceInfo();
            DeviceInfo.MobileOs = MobileOs.Android;
            DeviceInfo.DeviceModel = Build.Model;
            DeviceInfo.OsVersion = Build.VERSION.Release;
            DeviceInfo.IP = IP;
            var tm = (TelephonyManager)activity.GetSystemService(Context.TelephonyService);
            DeviceInfo.UniqueId = tm.DeviceId;
        }
开发者ID:vistaprint,项目名称:automobile,代码行数:18,代码来源:AndroidDevice.cs

示例5: OnElementChanged

        protected override void OnElementChanged(Xamarin.Forms.Platform.Android.ElementChangedEventArgs<Xamarin.Forms.Page> e)
        {
            base.OnElementChanged (e);

            mActivity = this.Context as Activity;
            mActivity.SetContentView (Resource.Layout.ConferencePageLayout);

            mPublisherViewContainer = (RelativeLayout) mActivity.FindViewById(Resource.Id.publisherview);
            mSubscriberViewContainer = (RelativeLayout) mActivity.FindViewById(Resource.Id.subscriberview);

            mStreams = new List<Stream>();
            SessionConnect();

            /*
            var activity = this.Context as Activity;
            var conferenceActivity = new Intent (activity, typeof (ConferenceActivity));
            activity.StartActivity (conferenceActivity);
            */
        }
开发者ID:ericgla,项目名称:XamarinOpenTok,代码行数:19,代码来源:ConferencePageRenderer.cs


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