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


C# Activity.FindViewById方法代码示例

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


在下文中一共展示了Activity.FindViewById方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: KeyboardNum

 /// <summary>
 /// 录入键盘
 /// </summary>
 /// <param name="activity">当前activity</param>
 /// <param name="GooCode">商品名</param>
 /// <param name="pageIndex">页码</param>
 /// <param name="Give">是否买赠</param>
 /// <param name="typeofString">返回页面</param>
 public KeyboardNum(Activity activity, string GooCode, int pageIndex, bool Give = false, string typeofString = "")
 {
     this.activity = activity;
     this.GooCode = GooCode;
     this.pageIndex = pageIndex;
     this.isGive = Give;
     this.typeofString = typeofString;
     LinearLayout KeyboardLinearLayout = activity.FindViewById<LinearLayout>(Resource.Id.KeyboardLinearLayout);
     EditText _Text = activity.FindViewById<EditText>(Resource.Id.KeyboardNumText);
     KeyboardLinearLayout.Visibility = ViewStates.Visible;
     _textNum = ""; _Text.Text = "";
     KeyboardNumClick();
 }
开发者ID:eatage,项目名称:AppTest,代码行数:21,代码来源:KeyboardNum.cs

示例4: ClientSocket

        public ClientSocket(Activity context)
        {
            _context = context;

            clientSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);

            ipText = _context.FindViewById<EditText>(Resource.Id.IPText);
            connectButton = _context.FindViewById<ImageButton>(Resource.Id.connectImageButton);

            var progress = new Progress<string>(s => ipText.Text = s);
            clientSocketReceiveThread = new Thread(() => clientSocketReceiveProc(progress));

            SmsReceiver.receivedSmsEvent += clientSocketSend;
        }
开发者ID:JrRjChan,项目名称:BotHelper,代码行数:14,代码来源:ClientSocket.cs

示例5: GetViewsTowers

        public void GetViewsTowers(Activity context)
        {
            listViews=new List<ImageView>();
            //var rlTowersViews=context.LayoutInflater.Inflate (Resource.Layout.TowerStateLayout, null);

            var rlTowersViews=context.FindViewById<RelativeLayout>(Resource.Id.towersState);

            //listViews.Add(rlTowersViews.FindViewById<ImageView> (Resource.Id.radiantAncient));
            //listViews.Add(rlTowersViews.FindViewById<ImageView> (Resource.Id.direAncient));

            listViews.Add(rlTowersViews.FindViewById<ImageView> (Resource.Id.radiantAncientBottom));
            listViews.Add(rlTowersViews.FindViewById<ImageView> (Resource.Id.radiantAncientTop));
            listViews.Add(rlTowersViews.FindViewById<ImageView> (Resource.Id.radiantBottomTier3));
            listViews.Add(rlTowersViews.FindViewById<ImageView> (Resource.Id.radiantBottomTier2));
            listViews.Add(rlTowersViews.FindViewById<ImageView> (Resource.Id.radiantBottomTier1));
            listViews.Add(rlTowersViews.FindViewById<ImageView> (Resource.Id.radiantMiddleTier3));
            listViews.Add(rlTowersViews.FindViewById<ImageView> (Resource.Id.radiantMiddleTier2));
            listViews.Add(rlTowersViews.FindViewById<ImageView> (Resource.Id.radiantMiddleTier1));
            listViews.Add(rlTowersViews.FindViewById<ImageView> (Resource.Id.radiantTopTier3));
            listViews.Add(rlTowersViews.FindViewById<ImageView> (Resource.Id.radiantTopTier2));
            listViews.Add(rlTowersViews.FindViewById<ImageView> (Resource.Id.radiantTopTier1));

            listViews.Add (null);
            listViews.Add (null);
            listViews.Add (null);
            listViews.Add (null);
            listViews.Add (null);
            listViews.Add(rlTowersViews.FindViewById<ImageView> (Resource.Id.radiantBottomRangedBarracks));
            listViews.Add(rlTowersViews.FindViewById<ImageView> (Resource.Id.radiantBottomMeleeBarracks));
            listViews.Add(rlTowersViews.FindViewById<ImageView> (Resource.Id.radiantMiddleRangedBarracks));
            listViews.Add(rlTowersViews.FindViewById<ImageView> (Resource.Id.radiantMeddleMeleeBarracks));
            listViews.Add(rlTowersViews.FindViewById<ImageView> (Resource.Id.radiantTopRangedBarracks));
            listViews.Add(rlTowersViews.FindViewById<ImageView> (Resource.Id.radiantTopMeleeBarracks));

            listViews.Add(rlTowersViews.FindViewById<ImageView> (Resource.Id.direAncientBottom));
            listViews.Add(rlTowersViews.FindViewById<ImageView> (Resource.Id.direAncientTop));
            listViews.Add(rlTowersViews.FindViewById<ImageView> (Resource.Id.direBottomTier3));
            listViews.Add(rlTowersViews.FindViewById<ImageView> (Resource.Id.direBottomTier2));
            listViews.Add(rlTowersViews.FindViewById<ImageView> (Resource.Id.direBottomTier1));
            listViews.Add(rlTowersViews.FindViewById<ImageView> (Resource.Id.direMiddleTier3));
            listViews.Add(rlTowersViews.FindViewById<ImageView> (Resource.Id.direMiddleTier2));
            listViews.Add(rlTowersViews.FindViewById<ImageView> (Resource.Id.direMiddleTier1));
            listViews.Add(rlTowersViews.FindViewById<ImageView> (Resource.Id.direTopTier3));
            listViews.Add(rlTowersViews.FindViewById<ImageView> (Resource.Id.direTopTier2));
            listViews.Add(rlTowersViews.FindViewById<ImageView> (Resource.Id.direTopTier1));
            //var lltowersState=Find

            listViews.Add (null);
            listViews.Add (null);
            listViews.Add (null);
            listViews.Add (null);
            listViews.Add (null);
            listViews.Add(rlTowersViews.FindViewById<ImageView> (Resource.Id.direBottomRangedBarracks));
            listViews.Add(rlTowersViews.FindViewById<ImageView> (Resource.Id.direBottomMeleeBarracks));
            listViews.Add(rlTowersViews.FindViewById<ImageView> (Resource.Id.direMiddleRangedBarracks));
            listViews.Add(rlTowersViews.FindViewById<ImageView> (Resource.Id.direMeddleMeleeBarracks));
            listViews.Add(rlTowersViews.FindViewById<ImageView> (Resource.Id.direTopRangedBarracks));
            listViews.Add(rlTowersViews.FindViewById<ImageView> (Resource.Id.direTopMeleeBarracks));
        }
开发者ID:mexaniksay,项目名称:GamePro02,代码行数:59,代码来源:TowersBaracksState.cs

示例6: InjectViews

        public void InjectViews(Activity activity)
        {
            OnInjecting(activity);

            injectByType(activity, typeof(InjectViewAttribute),
                (attribute, type) => activity.FindViewById(((InjectViewAttribute)attribute).ResourceId));

            OnInjected();
        }
开发者ID:jorik041,项目名称:Calibrate,代码行数:9,代码来源:BaseInjector.cs

示例7: AndroidBugfix5497

		private AndroidBugfix5497(Activity activity)
		{
			FrameLayout content = (FrameLayout)activity.FindViewById(Android.Resource.Id.Content);
			mChildOfContent = content.GetChildAt(0);
			ViewTreeObserver vto = mChildOfContent.ViewTreeObserver;
			vto.GlobalLayout += (object sender, EventArgs e) =>
			{
				possiblyResizeChildOfContent();
			};
			frameLayoutParams = (FrameLayout.LayoutParams)mChildOfContent.LayoutParameters;
		}
开发者ID:JudoPay,项目名称:Judo-Xamarin,代码行数:11,代码来源:AndroidBugfix5497.cs

示例8: GetEditText

        public static String GetEditText(Activity act, int resId)
        {
            TextView te =  (TextView) act.FindViewById(resId);
            System.Diagnostics.Debug.Assert(te != null);

            if (te != null) {
                return te.Text;
            } else {
                return "";
            }
        }
开发者ID:pythe,项目名称:wristpass,代码行数:11,代码来源:Util.cs

示例9: 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

示例10: ButtonItem

		public ButtonItem (Activity oActivity, Game oGame)
		{
			this.oActivity = oActivity;
			this.oGame = oGame;
			oImageButton = oActivity.FindViewById<ImageButton> (Int32.Parse( Game.buttons[nahodnik.Next(0,Game.buttons.Length-1)].ToString()));
			seznamVisibleButtons.Add (this);

			oActivity.RunOnUiThread (() => oImageButton.Visibility = ViewStates.Visible);
			oActivity.RunOnUiThread (() => oImageButton.Enabled = true);

			if (OptionsHodnoty.TouchMode) 
			{
				//oImageButton.Touch += HandleClick;
				//oImageButton.SetOnTouchListener (this);
			} else {
				oImageButton.Click += HandleClick;
			}
		}
开发者ID:OndrejMikulec,项目名称:Buttons,代码行数:18,代码来源:ButtonItem.cs

示例11: attachToActivity

        /**
         * Attaches the SlidingMenu to an entire Activity
         * 
         * @param activity the Activity
         * @param slideStyle either SLIDING_CONTENT or SLIDING_WINDOW
         * @param actionbarOverlay whether or not the ActionBar is overlaid
         */
        public void attachToActivity(Activity activity, int slideStyle, bool actionbarOverlay)
        {
            if (slideStyle != SLIDING_WINDOW && slideStyle != SLIDING_CONTENT)
                throw new Java.Lang.IllegalArgumentException("slideStyle must be either SLIDING_WINDOW or SLIDING_CONTENT");

            if (Parent != null)
                throw new Java.Lang.IllegalStateException("This SlidingMenu appears to already be attached");

            // get the window background
            TypedArray a = activity.Theme.ObtainStyledAttributes(new int[] { Android.Resource.Attribute.WindowBackground });
            int background = a.GetResourceId(0, 0);
            a.Recycle();

            switch (slideStyle)
            {
                case SLIDING_WINDOW:
                    mActionbarOverlay = false;
                    ViewGroup decor = (ViewGroup)activity.Window.DecorView;
                    ViewGroup decorChild = (ViewGroup)decor.GetChildAt(0);
                    // save ActionBar themes that have transparent assets
                    decorChild.SetBackgroundResource(background);
                    decor.RemoveView(decorChild);
                    decor.AddView(this);
                    setContent(decorChild);
                    break;
                case SLIDING_CONTENT:
                    mActionbarOverlay = actionbarOverlay;
                    // take the above view out of
                    ViewGroup contentParent = (ViewGroup)activity.FindViewById(Android.Resource.Id.Content);
                    View content = contentParent.GetChildAt(0);
                    contentParent.RemoveView(content);
                    contentParent.AddView(this);
                    setContent(content);
                    // save people from having transparent backgrounds
                    if (content.Background == null)
                        content.SetBackgroundResource(background);
                    break;
            }
        }
开发者ID:skywolf888,项目名称:SlidingMenu.Net,代码行数:46,代码来源:SlidingMenu.cs

示例12: SetGamePlayerNameText

 public static void SetGamePlayerNameText(Activity activity, int id, TetrisColor color)
 {
     TextView textView = activity.FindViewById<TextView>(id);
     textView.SetTextColor(Utils.getAndroidColor(color));
 }
开发者ID:lea-and-anthony,项目名称:Tetrim,代码行数:5,代码来源:UtilsUI.cs

示例13: SetContent

            private void SetContent(ActionBar.Tab tab, FragmentTransaction ft, int? placeHolder, Activity activity, ActionBar bar)
            {
                if (placeHolder == null)
                {
                    Tracer.Error("The placeholder for tab {0} was not found.", tab);
                    return;
                }
                var layout = activity.FindViewById<ViewGroup>(placeHolder.Value);
                if (layout == null)
                {
                    Tracer.Warn("The ActionBarTabContentId with id = {0} is not found in activity {1}",
                        placeHolder.Value,
                        activity);
                    return;
                }
                if (_content == null)
                {
#if APPCOMPAT
                    _content = tab.GetBindingMemberValue(AttachedMembersCompat.ActionBarTab.Content);
#else
                    _content = tab.GetBindingMemberValue(AttachedMembers.ActionBarTab.Content);
#endif

                    var viewModel = _content as IViewModel;
                    if (viewModel == null)
                    {
                        var fragmentClass = _content as string;
                        //If content is a string, trying to create a fragment.
                        if (!string.IsNullOrEmpty(fragmentClass))
                        {
                            var type = TypeCache<Fragment>.Instance.GetTypeByName(fragmentClass, true, false);
                            if (type != null)
                            {
                                var fragment = Fragment.Instantiate(bar.ThemedContext, Java.Lang.Class.FromType(type).Name);
                                _content = fragment;
                            }
                        }
                        else if (_content is int)
                            _content = activity.GetBindableLayoutInflater().Inflate((int)_content, null);
                    }
                    else
                        viewModel.Settings.Metadata.AddOrUpdate(ViewModelConstants.StateNotNeeded, true);
                    _content = PlatformExtensions.GetContentView(layout, layout.Context, _content,
                        _contentTemplateProvider.GetTemplateId(), _contentTemplateProvider.GetDataTemplateSelector());
                    layout.SetContentView(_content, ft, (@group, fragment, arg3) =>
                    {
                        if (fragment.IsDetached)
                            arg3.Attach(fragment);
                        else
                            arg3.Replace(@group.Id, fragment);
                    });
                }
                else
                    layout.SetContentView(_content, ft, (@group, fragment, arg3) => arg3.Attach(fragment));
            }
开发者ID:windygu,项目名称:MugenMvvmToolkit,代码行数:55,代码来源:ActionBarTabTemplate.cs

示例14: AttachToActivity

        public void AttachToActivity(Activity activity, SlideStyle slideStyle, bool actionbarOverlay)
        {
            if (Parent != null)
                throw new ArgumentException("This SlidingMenu appears to already be attached");

            // get the window background
            var a = activity.Theme.ObtainStyledAttributes(new[] { Android.Resource.Attribute.WindowBackground });
            var background = a.GetResourceId(0, 0);
            a.Recycle();

            switch (slideStyle)
            {
                case SlideStyle.Window:
                    _mActionbarOverlay = false;
                    var decor = (ViewGroup)activity.Window.DecorView;
                    var decorChild = (ViewGroup)decor.GetChildAt(0);
                    // save ActionBar themes that have transparent assets
                    decorChild.SetBackgroundResource(background);
                    decor.RemoveView(decorChild);
                    decor.AddView(this);
                    SetContent(decorChild);
                    break;
                case SlideStyle.Content:
                    _mActionbarOverlay = actionbarOverlay;
                    // take the above view out of
                    var contentParent = (ViewGroup)activity.FindViewById(Android.Resource.Id.Content);
                    var content = contentParent.GetChildAt(0);
                    contentParent.RemoveView(content);
                    contentParent.AddView(this);
                    SetContent(content);
                    // save people from having transparent backgrounds
                    if (content.Background == null)
                        content.SetBackgroundResource(background);
                    break;
            }
        }
开发者ID:kobynet,项目名称:SlidingMenuSharp,代码行数:36,代码来源:SlidingMenu.cs

示例15: SetActionBarMargin

 private void SetActionBarMargin(ViewGroup.MarginLayoutParams parameters, Activity activity)
 {
     int actionBarContainerId = Android.Content.Res.Resources.System.GetIdentifier("action_bar_container", "id", "android");
     View actionBarContainer = activity.FindViewById(actionBarContainerId);
     // The action bar is present: the app is using a Holo theme.
     if (null != actionBarContainer)
     {
         parameters.TopMargin = actionBarContainer.Bottom;
     }
 }
开发者ID:NimaGhaedsharafi,项目名称:ToastsRTL.Forms.Plugin,代码行数:10,代码来源:Manager.cs


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