本文整理汇总了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);
}
示例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);
}
示例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();
}
示例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;
}
示例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));
}
示例6: InjectViews
public void InjectViews(Activity activity)
{
OnInjecting(activity);
injectByType(activity, typeof(InjectViewAttribute),
(attribute, type) => activity.FindViewById(((InjectViewAttribute)attribute).ResourceId));
OnInjected();
}
示例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;
}
示例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 "";
}
}
示例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;
}
}
}
}
}
示例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;
}
}
示例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;
}
}
示例12: SetGamePlayerNameText
public static void SetGamePlayerNameText(Activity activity, int id, TetrisColor color)
{
TextView textView = activity.FindViewById<TextView>(id);
textView.SetTextColor(Utils.getAndroidColor(color));
}
示例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));
}
示例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;
}
}
示例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;
}
}