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); }
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); }
/// <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(); }
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; }
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)); }
public void InjectViews(Activity activity) { OnInjecting(activity); injectByType(activity, typeof(InjectViewAttribute), (attribute, type) => activity.FindViewById(((InjectViewAttribute)attribute).ResourceId)); OnInjected(); }
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; }
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 ""; } }
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; } } } } }
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; } }
public static void ShowHelp(Android.App.Activity context, string link) { var builder = new CustomTabsIntent.Builder() .SetToolbarColor(ContextCompat.GetColor(context, Resource.Color.blue)) .SetSecondaryToolbarColor(Android.Resource.Color.White) .SetShowTitle(true); Bitmap icon; if (ViewCompat.GetLayoutDirection(context.FindViewById <ViewGroup>(Android.Resource.Id.Content).GetChildAt(0)) != ViewCompat.LayoutDirectionRtl) { icon = BitmapFactory.DecodeResource(context.Resources, Resource.Drawable.ic_arrow_back_white_24dp); } else { icon = BitmapFactory.DecodeResource(context.Resources, Resource.Drawable.ic_arrow_forward_white_24dp); } builder.SetCloseButtonIcon(icon); var intent = builder.Build(); intent.Intent.PutExtra(Intent.ExtraReferrer, Android.Net.Uri.Parse("app://" + context.PackageName)); intent.LaunchUrl(context, Android.Net.Uri.Parse(context.Resources.GetString(Resource.String.HelpLink) + link)); }
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)); }
public static void SetGamePlayerNameText(Activity activity, int id, TetrisColor color) { TextView textView = activity.FindViewById<TextView>(id); textView.SetTextColor(Utils.getAndroidColor(color)); }
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; } }
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; } }
public static ShowcaseView InsertShowcaseViewWithType(int type, int itemId, Activity activity, int title, int detailText, ConfigOptions options) { ShowcaseView sv = new ShowcaseView(activity); if (options != null) { sv.ConfigurationOptions = options; } if (sv.ConfigurationOptions.Insert == INSERTTODECOR) { ((ViewGroup)activity.Window.DecorView).AddView(sv); } else { ((ViewGroup)activity.FindViewById(Android.Resource.Id.Content)).AddView(sv); } sv.SetShowcaseItem(type, itemId, activity); sv.SetText(title, detailText); return sv; }
private void OnUploadDoneDlg(Activity callingAct,int count,string msg) { Button butupload = callingAct.FindViewById<Button> (Resource.Id.butupload); butupload.Text = Resources.GetString(Resource.String.submenu_upinv);// "UPLOAD INVOICE"; butupload.Enabled = true; if (count > 0) { //string dispmsg = "Total " + count.ToString () + " invoices uploaded."; string dispmsg =Resources.GetString(Resource.String.msg_uploadinv); dispmsg = dispmsg.Replace ("xx", count.ToString ()); Toast.MakeText (this, dispmsg, ToastLength.Long).Show (); } else { Toast.MakeText (this, msg, ToastLength.Long).Show (); } }
public static void SetGamePlayerNameText(Activity activity, int id, bool me) { TextView textView = activity.FindViewById<TextView>(id); textView.SetTextColor(Utils.getAndroidColor(me ? TetrisColor.Cyan : TetrisColor.Red)); }
public static void SetActivityTheme(Activity activity, FlatTheme theme) //, bool includeNormalViews) { ViewGroup vg = activity.FindViewById<View>(Android.Resource.Id.Content) as ViewGroup; if (vg == null) return; SetThemeOnChildren(vg, theme, false); }
private void InitializeUi(Activity activity) { if (IsUiInitialized) return; _startButton = activity.FindViewById<Button>(Resource.Id.StartButton); _startButton.Enabled = EnableStartButtonFlag; _cancelButton = activity.FindViewById<Button>(Resource.Id.CancelButton); _feedbackButton = activity.FindViewById<Button>(Resource.Id.FeedbackButton); _statusText = activity.FindViewById<TextView>(Resource.Id.StatusText); _resultText = activity.FindViewById<TextView>(Resource.Id.Result); _animationView = activity.FindViewById<ImageView>(Resource.Id.AnimationView); _smartPhoneView = activity.FindViewById<ImageView>(Resource.Id.SmartphoneImage); _resultViews = activity.FindViewById<LinearLayout>(Resource.Id.ResultsView); _countdownText = activity.FindViewById<TextView>(Resource.Id.CountdownText); _manualText = activity.FindViewById<TextView>(Resource.Id.ManualText1); _manualText2 = activity.FindViewById<TextView>(Resource.Id.ManualText2); _progressBar = activity.FindViewById<SeekBar>(Resource.Id.SeekBar); _progressBar.SetOnSeekBarChangeListener(this); _progressBar.Touch += OnTouchProgressBar; _progressBar.SetThumb(activity.Resources.GetDrawable(Resource.Drawable.thumb_green)); _progressBar.ProgressDrawable = activity.Resources.GetDrawable(Resource.Drawable.progress_seekbar_green); _progressBar.Max = MaxProgress; _progressBar.Progress = 0; _dontShowAgainBox = activity.FindViewById<CheckBox>(Resource.Id.DontShowAgainBox); _dontShowAgainBox.Visibility = ViewStates.Invisible; var preferences = PreferenceManager.GetDefaultSharedPreferences(SkillStoreApplication.AppContext); _dontShowAgainBox.Checked = preferences.GetBoolean(SettingsKey.ShowAgainPreference, false); IsUiInitialized = true; }
public static ShowcaseView InsertShowcaseView(View viewToShowcase, Activity activity, String title, String detailText, ConfigOptions options) { var sv = new ShowcaseView(activity); if (options != null) { sv.ConfigurationOptions = options; } if (sv.ConfigurationOptions.Insert == INSERTTODECOR) { ((ViewGroup)activity.Window.DecorView).AddView(sv); } else { ((ViewGroup)activity.FindViewById(Android.Resource.Id.Content)).AddView(sv); } sv.SetShowcaseView(viewToShowcase); sv.SetText(title, detailText); return sv; }
public static ShowcaseView InsertShowcaseView(int showcaseViewId, Activity activity, int title, int detailText, ConfigOptions options) { View v = activity.FindViewById(showcaseViewId); if (v != null) { return InsertShowcaseView(v, activity, title, detailText, options); } return null; }
static public void ShowToast(Activity activity, string message, ToastLength duration = ToastLength.Short){ LayoutInflater inflater = activity.LayoutInflater; View layout = inflater.Inflate(Resource.Layout.toast, (ViewGroup) activity.FindViewById(Resource.Id.toast_layout_root)); TextView text = (TextView) layout.FindViewById(Resource.Id.toast_text); text.SetText(message, TextView.BufferType.Normal); Toast toast = new Toast(activity.ApplicationContext); toast.SetGravity(GravityFlags.CenterVertical, 0, 0); toast.Duration = duration; toast.View = layout; toast.Show(); }
// Internal insert method so all inserts are routed through one method static ShowcaseView InsertShowcaseViewInternal(ITarget target, Activity activity, String title, String detail, ConfigOptions options) { var sv = new ShowcaseView(activity); sv.ConfigurationOptions = options; if (sv.ConfigurationOptions.Insert == INSERTTODECOR) { ((ViewGroup)activity.Window.DecorView).AddView(sv); } else { ((ViewGroup)activity.FindViewById(Android.Resource.Id.Content)).AddView(sv); } sv.SetShowcase(target); sv.SetText(title, detail); return sv; }
/** * 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; } }
public static void SetEditText(Activity act, int resId, String str) { TextView te = (TextView) act.FindViewById(resId); System.Diagnostics.Debug.Assert(te != null); if (te != null) { te.Text = str; } }
public static void SetGamePlayerStatText(Activity activity, int id, bool me, bool isTitle, TetrisColor color) { TextView textView = activity.FindViewById<TextView>(id); textView.SetBackgroundColor(Utils.getAndroidColor(color)); textView.SetTextColor(!isTitle ? (me ? UtilsUI.Player1Background : UtilsUI.Player2Background) : Utils.getAndroidDarkColor(color)); }
private void OnUploadDoneDlg(Activity callingAct,int count,string msg) { Button butupload = callingAct.FindViewById<Button> (Resource.Id.butupload); butupload.Enabled = true; if (count > 0) { string dispmsg = "Total " + count.ToString () + " invoices uploaded."; Toast.MakeText (this, dispmsg, ToastLength.Long).Show (); } else { Toast.MakeText (this, msg, ToastLength.Long).Show (); } }
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); */ }
/// <summary> /// Snaps the specified view in the activity. /// </summary> /// <param name="activity">The activity.</param> /// <param name="resourceId">The resource identifier.</param> /// <returns>The screenshot bitmap.</returns> public static Bitmap Snap(Activity activity, int resourceId) { return Snap(activity.FindViewById(resourceId)); }
public static ShowcaseView InsertShowcaseView(int x, int y, Activity activity, int title, int detailText, ConfigOptions options) { var showcaseView = new ShowcaseView(activity); if (options != null) { showcaseView.ConfigurationOptions = options; } if (showcaseView.ConfigurationOptions.Insert == INSERTTODECOR) { ((ViewGroup)activity.Window.DecorView).AddView(showcaseView); } else { ((ViewGroup)activity.FindViewById(Android.Resource.Id.Content)).AddView(showcaseView); } showcaseView.SetShowcasePosition(x, y); showcaseView.SetText(title, detailText); return showcaseView; }