本文整理汇总了C#中Android.Views.View.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# View.GetType方法的具体用法?C# View.GetType怎么用?C# View.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Android.Views.View
的用法示例。
在下文中一共展示了View.GetType方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateEventHandler
protected Delegate CreateEventHandler(object target, View view, MethodMapping methodMapping, out EventInfo evnt)
{
Delegate del = null;
evnt = null;
if (view != null)
{
evnt = view.GetType().GetEvent(methodMapping.Attribute.EventName);
if (evnt != null)
{
try
{
del = CreateDelegate(target, methodMapping, evnt);
}
catch (Exception ex)
{
Geneticist.HandleError(
ex,
"Error creating delegate from '{0}' for event '{1}'.",
methodMapping.Method.Name,
methodMapping.Attribute.EventName);
}
}
else
{
Geneticist.HandleError(
"Unable to find event '{0}' for method '{1}'.",
methodMapping.Attribute.EventName,
methodMapping.Method.Name);
}
}
return del;
}
示例2: setupParent
// hide keyboard when clicking anywhere but EditText
protected void setupParent(View view)
{
//Set up touch listener for non-text box and not checkbox views to hide keyboard.
if (!(view.OnCheckIsTextEditor()) && view.GetType() != typeof (CheckBox)
&& view.Id != Resource.Id.colorsCheckBoxesLayout)
{
view.Touch += (sender, args) => { hideSoftKeyboard(); };
}
//If a layout container, iterate over children
if (view.GetType().BaseType == typeof(ViewGroup))
{
for (int i = 0; i < ((ViewGroup) view).ChildCount; i++) {
View innerView = ((ViewGroup) view).GetChildAt(i);
setupParent(innerView);
}
}
}
示例3: Binding
public Binding(View target, string targetProperty, object source, string sourceProperty, Func<object, object> convert, Func<object, object> convertBack)
{
Target = target;
Source = source;
TargetProperty = Target.GetType().GetProperty(targetProperty);
SourceProperty = Source.GetType().GetProperty(sourceProperty);
Convert = convert;
ConvertBack = convertBack;
Target.FocusChange += Target_FocusChange;
var inpc = Source as INotifyPropertyChanged;
if (inpc != null)
inpc.PropertyChanged += Source_PropertyChanged;
UpdateTarget();
}
示例4: UpdateView
public static void UpdateView(View view, object value)
{
if (view != null)
{
string viewTypeName = view.GetType().FullName;
switch (viewTypeName)
{
// TODO: Add cases here for specialized view types, as needed
case "Android.Widget.ProgressBar":
{
var progressBar = (ProgressBar)view;
int progressValue = (int)(value ?? 0);
if (progressBar.Progress != progressValue) progressBar.Progress = progressValue;
}
break;
case "Android.Webkit.WebView":
{
var webView = (Android.Webkit.WebView)view;
if (value is Uri)
{
string newUrl = value.ToString();
if (webView.Url != newUrl) webView.LoadUrl(newUrl);
}
else
{
webView.LoadData(value == null ? "" : value.ToString(), "text/html", null);
}
}
break;
case "Macaw.UIComponents.MultiImageView":
{
if (value is Uri) value = ((Uri)value).AbsoluteUri;
var multiImageView = (Macaw.UIComponents.MultiImageView)view;
multiImageView.LoadImageList(value == null ? null : new[] { (string)value });
multiImageView.LoadImage(); // TODO: Update to MultiImageView 1.2 when it is published, to fix hang on no connection and to get rid of this LoadImage call.
}
break;
default:
if (view is TextView)
{
var textView = (TextView)view;
string text = value == null ? "" : value.ToString();
if (textView.Text != text) textView.Text = text;
}
else if (view is AdapterView)
{
var adapterView = (AdapterView)view;
var adapter = adapterView.GetAdapter() as IDataBindableListAdapter;
if (adapter != null)
{
int position = adapter.GetItemPosition(value);
if (adapterView is AbsListView)
{
var absListView = (AbsListView)adapterView;
if (!absListView.IsItemChecked(position))
{
absListView.SetItemChecked(position, true);
}
}
else
{
if (adapterView.SelectedItemPosition != position) adapterView.SetSelection(position);
}
}
}
else throw new NotImplementedException("View type not implemented: " + viewTypeName);
break;
}
}
}
示例5: ViewDrawerIsOpenedGetDefaultValue
private static bool ViewDrawerIsOpenedGetDefaultValue(View view, IBindingMemberInfo bindingMemberInfo)
{
DrawerLayout drawer = FindDrawer(view);
if (drawer == null)
{
IBindingMemberInfo rootMember = BindingServiceProvider.VisualTreeManager.GetRootMember(view.GetType());
if (rootMember != null)
rootMember.TryObserve(view, DrawerInitializer.Instance);
return false;
}
DrawerListenerImpl.GetOrAdd(drawer);
return drawer.IsDrawerOpen(view);
}
示例6: BindViewTree
/// <summary>
/// Traverses the view hierarchy and updates the bindings.
/// </summary>
protected void BindViewTree(object dataSource, View view, IList<WeakReference> reusableBindings = null) {
var tag = view.GetBindingTag ();
if (tag != null) {
if (!tag.BindingEnabled)
return;
if (tag.OverrideDataSource)
dataSource = tag.DataSource;
if (tag.BindingDescriptions != null) {
if (dataSource == null) {
MvxBindingTrace.Trace(
MvxTraceLevel.Warning,
"Binding view {0} with an empty data source.",
view.GetType().Name);
}
if (tag.Bindings.Count > 0 || dataSource != null) {
// Try to reuse weak reference for the tag:
WeakReference weakTag = null;
if (reusableBindings != null) {
for (var i = 0; i < reusableBindings.Count; i++) {
if (reusableBindings[i] == null)
continue;
if (reusableBindings[i].Target == tag) {
weakTag = reusableBindings[i];
reusableBindings[i] = null;
}
}
}
if (weakTag == null)
weakTag = new WeakReference(tag);
_viewTags.Add(weakTag);
if (tag.Bindings.Count > 0) {
// Update old bindings only:
foreach (var binding in tag.Bindings) {
binding.DataContext = dataSource;
}
} else {
// Create bindings:
var bindings = this.GetService<IMvxBinder>()
.Bind(dataSource, view, tag.BindingDescriptions);
if (bindings != null) {
foreach (var binding in bindings) {
tag.Bindings.Add(binding);
}
}
}
}
}
}
var viewGroup = view as ViewGroup;
if (viewGroup != null) {
var count = viewGroup.ChildCount;
for (var i = 0; i < count; i++) {
BindViewTree(dataSource, viewGroup.GetChildAt(i), reusableBindings);
}
}
}
示例7: GetDataContext
protected virtual IDataContext GetDataContext(View view, Context context, IAttributeSet attrs)
{
var dataContext = new DataContext();
var strings = ReadStringAttributeValue(context, attrs, Resource.Styleable.Binding, BindingAttrIndex);
if (strings != null && strings.Count != 0)
dataContext.Add(ViewFactoryConstants.Bindings, strings);
SetAttributeValue(view, context, attrs, Resource.Styleable.ItemsControl,
Resource.Styleable.ItemsControl_ItemTemplate, AttachedMemberConstants.ItemTemplate, dataContext,
ViewFactoryConstants.ItemTemplateId);
SetAttributeValue(view, context, attrs, Resource.Styleable.ItemsControl,
Resource.Styleable.ItemsControl_DropDownItemTemplate, AttachedMembers.AdapterView.DropDownItemTemplate,
dataContext,
ViewFactoryConstants.DropDownItemTemplateId);
SetAttributeValue(view, context, attrs, Resource.Styleable.Control,
Resource.Styleable.Control_ContentTemplate, AttachedMemberConstants.ContentTemplate, dataContext,
ViewFactoryConstants.ContentTemplateId);
SetAttributeValue(view, context, attrs, Resource.Styleable.Menu,
Resource.Styleable.Menu_MenuTemplate, AttachedMembers.Toolbar.MenuTemplate, dataContext,
ViewFactoryConstants.MenuTemplateId);
SetAttributeValue(view, context, attrs, Resource.Styleable.Menu,
Resource.Styleable.Menu_PopupMenuTemplate, AttachedMembers.View.PopupMenuTemplate, dataContext,
ViewFactoryConstants.PopupMenuTemplateId);
strings = ReadStringAttributeValue(context, attrs, Resource.Styleable.Menu,
new[] { Resource.Styleable.Menu_PopupMenuEvent });
if (strings != null && strings.Count > 0)
{
string eventName = strings[0];
dataContext.Add(ViewFactoryConstants.PopupMenuEvent, eventName);
IBindingMemberInfo member = BindingServiceProvider
.MemberProvider
.GetBindingMember(view.GetType(), AttachedMembers.View.PopupMenuEvent, false, false);
if (member != null)
member.SetSingleValue(view, eventName);
}
strings = ReadStringAttributeValue(context, attrs, Resource.Styleable.Menu,
new[] { Resource.Styleable.Menu_PlacementTargetPath });
if (strings != null && strings.Count > 0)
{
string path = strings[0];
dataContext.Add(ViewFactoryConstants.PlacementTargetPath, path);
IBindingMemberInfo member = BindingServiceProvider
.MemberProvider
.GetBindingMember(view.GetType(), AttachedMembers.View.PopupMenuPlacementTargetPath, false, false);
if (member != null)
member.SetSingleValue(view, path);
}
return dataContext;
}
示例8: SetAttributeValue
private static void SetAttributeValue(View view, Context context, IAttributeSet attrs, int[] groupId,
int requiredAttributeId, string attachedMemberName, IDataContext dataContext, DataConstant<int> constant)
{
int? value = ReadAttributeValueId(context, attrs, groupId, requiredAttributeId);
if (!value.HasValue)
return;
dataContext.Add(constant, value.Value);
IBindingMemberInfo member = BindingServiceProvider
.MemberProvider
.GetBindingMember(view.GetType(), attachedMemberName, false, false);
if (member != null)
member.SetSingleValue(view, value);
}
示例9: AddView
public override void AddView (View child)
{
try {
base.AddView (child);
} catch {
Console.WriteLine ("!!!! Caught exception: Failed to add View: " + child.GetType ());
}
}
示例10: CallMappingOnView
/**
* Called when a view loaded and call a mapping function
*
* @param view the calling view
* @param mappedObject If available, the object to map with the view. Else add the view to mappingWaitings
*/
public void CallMappingOnView(CarpaccioAction action, View view, Object mappedObject) {
if (action.IsCallMapping) {
CarpaccioLogger.d(TAG, "callMappingOnView mapping=" + mappedObject + " action=" + action.CompleteCall + " view=" + view.GetType().Name);
string arg = action.Args[0]; //only map the first argument
string objectName;
string call;
if (arg.Contains(".")) { //"$user.getName()"
call = arg.Substring(1, arg.Length - 1); // "user.getName()"
objectName = call.Substring(0, arg.IndexOf('.') - 1); // "user"
} else {
objectName = arg.Substring(1, arg.Length - 1); // "user"
call = objectName; // "user"
}
//if you already have the object
if (mappedObject != null) {
string value = Evaluate(mappedObject, call);
CarpaccioLogger.d(TAG, "callMappingOnView evaluate(" + call + ")" + " on " + mappedObject.GetType().Name + " returned " + value);
action.Values = new[]{value}; //TODO
MappingManagerCallback.CallActionOnView(action, view);
} else {
//add to waiting
List<MappingWaiting> waitings = MappingWaitings.GetOrDefault(objectName) ?? new List<MappingWaiting>(); //["user"] = List<MappingWaiting>
waitings.Add(new MappingWaiting(view, action, call, objectName));
CarpaccioLogger.d(TAG, "added to waiting " + call + " for " + view.GetType().Name);
MappingWaitings.AddOrUpdate(objectName, waitings);
}
}
}
示例11: UpdateView
public static void UpdateView(View view, object value)
{
if (view != null)
{
string viewTypeName = view.GetType().FullName;
switch (viewTypeName)
{
// TODO: Add cases here for specialized view types, as needed
case "Android.Widget.ProgressBar":
{
var progressBar = (ProgressBar)view;
int progressValue = (int)(value ?? 0);
if (progressBar.Progress != progressValue) progressBar.Progress = progressValue;
}
break;
case "Android.Webkit.WebView":
{
var webView = (Android.Webkit.WebView)view;
if (value is Uri)
{
string newUrl = value.ToString();
if (webView.Url != newUrl) webView.LoadUrl(newUrl);
}
else
{
webView.LoadData(value == null ? "" : value.ToString(), "text/html", null);
}
}
break;
default:
if (view is TextView)
{
var textView = (TextView)view;
string text = value == null ? "" : value.ToString();
if (textView.Text != text) textView.Text = text;
}
else if (view is AdapterView)
{
var adapterView = (AdapterView)view;
var adapter = adapterView.GetAdapter() as IDataBindableListAdapter;
if (adapter != null)
{
int position = adapter.GetItemPosition(value);
if (adapterView is AbsListView)
{
var absListView = (AbsListView)adapterView;
if (!absListView.IsItemChecked(position))
{
absListView.SetItemChecked(position, true);
}
}
else
{
if (adapterView.SelectedItemPosition != position) adapterView.SetSelection(position);
}
}
}
else throw new NotImplementedException("View type not implemented: " + viewTypeName);
break;
}
}
}