本文整理汇总了C#中Android.Views.View类的典型用法代码示例。如果您正苦于以下问题:C# View类的具体用法?C# View怎么用?C# View使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
View类属于Android.Views命名空间,在下文中一共展示了View类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnTouch
// Check touch position on button
public bool OnTouch(View v, MotionEvent e)
{
switch (e.Action)
{
// Get the x and y position for a touch (always before move)
case MotionEventActions.Down:
old_x = e.GetX ();
old_y = e.GetY ();
Console.WriteLine ("x = " + old_x + " y = " + old_y);
break;
// Get the x and y position difference continously
case MotionEventActions.Move:
// Get the difference between current position and old position
new_x = e.GetX () - old_x;
new_y = e.GetY () - old_y;
// Convert to int, to remove decimal numbers (apparently can't be send through the tcp listener)
int_x = Convert.ToInt32 (new_x);
int_y = Convert.ToInt32 (new_y);
// Convert to string, so it can be send
send_x = Convert.ToString (int_x);
send_y = Convert.ToString (int_y);
// Send x and y position over two messages
Connect (ipAddress, send_x);
Connect (ipAddress, send_y);
// Set old position to current position
old_x = e.GetX ();
old_y = e.GetY ();
break;
}
return true;
}
示例2: OnCreate
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
SetContentView(Resource.Layout.Main);
_view = FindViewById<LinearLayout>(Resource.Id.parentLayout);
_text = FindViewById<TextView>(Resource.Id.logTextView);
UpdateDisplay(INITIAL_MESSAGE,Color.White);
var beaconManager = new BeaconManager(this);
indoorLocationController = new IndoorLocationController(beaconManager);
indoorLocationController.BeaconFound += HandleBeaconFound;
indoorLocationController.BeaconLost += HandleBeaconLost;
var beacon1 = DummyBeaconCreator.CreateBeaconUrsin();
var beacon2 = DummyBeaconCreator.CreateBeaconMarcel();
indoorLocationController.AddBeaconsAndStart(new List<Beacon>{beacon1,beacon2});
if (!IsBluetoothAvailable)
{
Toast.MakeText(this, "Please activate Bluetooth! iBeacons works only when Bluetooth available.",ToastLength.Long).Show();
}
}
示例3: OnListItemClick
protected override void OnListItemClick(ListView l, View v, int position, long id)
{
var url = _adapter.GetMapUrl (position);
var intent = new Intent (Intent.ActionView, Uri.Parse(url));
StartActivity (intent);
}
示例4: DeleteClicked
private void DeleteClicked(View view)
{
var vm = GetViewVm(view);
_dataContext.DeleteTodo(vm.Todo);
_todoVms.Remove(vm);
NotifyDataSetChanged(); // trigger view reset so item disappears
}
示例5: Initialize
private void Initialize (Context ctx)
{
var dm = ctx.Resources.DisplayMetrics;
var inflater = LayoutInflater.FromContext (ctx);
overlayInset = (int)TypedValue.ApplyDimension (ComplexUnitType.Dip, 45, dm);
backgroundView = new SliceView (ctx) {
StartAngle = 0,
EndAngle = 360,
Color = emptyPieColor,
};
AddView (backgroundView);
loadingOverlayView = inflater.Inflate (Resource.Layout.PieChartLoading, this, false);
AddView (loadingOverlayView);
emptyOverlayView = inflater.Inflate (Resource.Layout.PieChartEmpty, this, false);
emptyOverlayView.Visibility = ViewStates.Gone;
AddView (emptyOverlayView);
statsOverlayView = inflater.Inflate (Resource.Layout.PieChartStats, this, false);
statsOverlayView.Visibility = ViewStates.Gone;
AddView (statsOverlayView);
statsTimeTextView = statsOverlayView.FindViewById<TextView> (Resource.Id.TimeTextView);
statsMoneyTextView = statsOverlayView.FindViewById<TextView> (Resource.Id.MoneyTextView);
Click += delegate {
// Deselect slices on click. The Clickable property is set to true only when a slice is selected.
ActiveSlice = -1;
};
Clickable = false;
}
示例6: CreateView
public virtual View CreateView(View parent, string name, Context context, IAttributeSet attrs)
{
// resolve the tag name to a type
var viewType = ViewTypeResolver.Resolve(name);
if (viewType == null)
{
//MvxBindingTrace.Trace(MvxTraceLevel.Error, "View type not found - {0}", name);
return null;
}
try
{
var view = Activator.CreateInstance(viewType, context, attrs) as View;
if (view == null)
{
MvxBindingTrace.Trace(MvxTraceLevel.Error, "Unable to load view {0} from type {1}", name,
viewType.FullName);
}
return view;
}
catch (ThreadAbortException)
{
throw;
}
catch (Exception exception)
{
MvxBindingTrace.Trace(MvxTraceLevel.Error,
"Exception during creation of {0} from type {1} - exception {2}", name,
viewType.FullName, exception.ToLongString());
return null;
}
}
示例7: OnViewCreated
public override void OnViewCreated (View view, Bundle savedInstanceState)
{
base.OnViewCreated (view, savedInstanceState);
ListView.SetClipToPadding (false);
ListAdapter = new SettingsAdapter ();
}
示例8: OnCreateView
public override View OnCreateView (LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
View v = inflater.Inflate (Resource.Layout.WebViewDialog, container, false);
txtTitle = v.FindViewById<TextView> (Resource.Id.txt_dialog_title);
divider = v.FindViewById<View> (Resource.Id.title_divider);
webView = v.FindViewById<WebView> (Resource.Id.dialog_web_view);
if (title == null || title.Length < 1) {
txtTitle.Visibility = divider.Visibility = ViewStates.Gone;
} else {
txtTitle.Text = title;
}
if (url != null && url.Length > 0) {
webView.LoadUrl (url);
}
if (showOkay) {
btnOk.Visibility = ViewStates.Visible;
btnOk.Click += (object sender, EventArgs e) => {
this.Dismiss ();
};
}
return v;
}
示例9: GetView
public override View GetView (Context context, View convertView, ViewGroup parent)
{
var view = new RelativeLayout(context);
var parms = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent,
ViewGroup.LayoutParams.WrapContent);
view.SetMinimumHeight(150);
parms.SetMargins(5, 3, 5, 0);
parms.AddRule(LayoutRules.AlignParentLeft);
_caption = new TextView (context);
SetCaption (Caption);
view.AddView(_caption, parms);
if (!String.IsNullOrWhiteSpace (Indicator)) {
var tparms = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent,
ViewGroup.LayoutParams.WrapContent);
tparms.SetMargins(5, 3, 5, 5);
tparms.AddRule(LayoutRules.CenterVertical);
tparms.AddRule(LayoutRules.AlignParentRight);
_text = new TextView (context) {
Text = Indicator,
TextSize = 22f
};
view.AddView(_text, tparms);
}
return view;
}
示例10: OnListItemClick
public override void OnListItemClick(ListView p0, View p1, int position, long p3)
{
Fragment newContent = null;
switch (position)
{
case 0:
newContent = new ColorFragment(Resource.Color.red);
break;
case 1:
newContent = new ColorFragment(Resource.Color.green);
break;
case 2:
newContent = new ColorFragment(Resource.Color.blue);
break;
case 3:
newContent = new ColorFragment(Resource.Color.white);
break;
case 4:
newContent = new ColorFragment(Resource.Color.black);
break;
}
if (newContent != null)
SwitchFragment(newContent);
}
示例11: GetChildView
public override View GetChildView(int groupPosition, int childPosition, bool isLastChild, View convertView, ViewGroup parent) {
View container = View.Inflate(parent.Context, Resource.Layout.list_item_child, null);
TextView txtGroupName = (TextView)container.FindViewById(Resource.Id.txtExampleName);
ExampleFragment child = (ExampleFragment)this.GetChild(groupPosition, childPosition);
txtGroupName.Text = child.Title();
return container;
}
示例12: CreateTabContent
public View CreateTabContent(string tag)
{
var v = new View(_context);
v.SetMinimumHeight(0);
v.SetMinimumWidth(0);
return v;
}
示例13: OnCreateView
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
view = inflater.Inflate(Resource.Layout.TeamsFragment, container, false);
if(listTeams.Count == 0) {
//display text that there are currently no events and hide list with events
view.FindViewById(Resource.Id.teamsFragmentListTeams).Visibility = ViewStates.Gone;
} else {
//display list with events and hide the text
view.FindViewById(Resource.Id.teamsFragmentNoTeams).Visibility = ViewStates.Gone;
listView = view.FindViewById<ListView>(Resource.Id.teamsFragmentListTeams);
listView.Adapter = new ListTeamsAdapter(this, listTeams);
listView.ItemClick += OnListItemClick;
}
if(DB_Communicator.getInstance().isAtLeast(VBUser.GetUserFromPreferences().getUserType(), UserType.Coremember)) {
view.FindViewById<LinearLayout>(Resource.Id.teamsFragmentBtnAddLine).Visibility = ViewStates.Visible;
} else {
view.FindViewById<LinearLayout>(Resource.Id.teamsFragmentBtnAddLine).Visibility = ViewStates.Gone;
}
view.FindViewById<Button>(Resource.Id.teamsFragmentBtnAdd).Click += (object sender, EventArgs e) => {
ViewController.getInstance().mainActivity.switchFragment(ViewController.TEAMS_FRAGMENT,
ViewController.ADD_TEAM_FRAGMENT, new AddTeamFragment());
};
return view;
}
示例14: GetView
public override View GetView(Context context, View convertView, ViewGroup parent)
{
this.Click = delegate { SelectImage(); };
Bitmap scaledBitmap = Bitmap.CreateScaledBitmap(_image, dimx, dimy, true);
var view = convertView as RelativeLayout;
if (view == null)
{
view = new RelativeLayout(context);
_imageView = new ImageView(context);
}
else
{
_imageView = (ImageView)view.GetChildAt(0);
}
_imageView.SetImageBitmap(scaledBitmap);
var parms = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent);
parms.SetMargins(5, 2, 5, 2);
parms.AddRule( LayoutRules.AlignParentLeft);
if(_imageView.Parent != null && _imageView.Parent is ViewGroup)
((ViewGroup)_imageView.Parent).RemoveView(_imageView);
view.AddView(_imageView, parms);
return view;
}
示例15: GetCellCore
protected override AView GetCellCore(Cell item, AView convertView, ViewGroup parent, Context context)
{
Performance.Start();
var cell = (ViewCell)item;
var container = convertView as ViewCellContainer;
if (container != null)
{
container.Update(cell);
Performance.Stop();
return container;
}
BindableProperty unevenRows = null, rowHeight = null;
if (ParentView is TableView)
{
unevenRows = TableView.HasUnevenRowsProperty;
rowHeight = TableView.RowHeightProperty;
}
else if (ParentView is ListView)
{
unevenRows = ListView.HasUnevenRowsProperty;
rowHeight = ListView.RowHeightProperty;
}
IVisualElementRenderer view = Platform.CreateRenderer(cell.View);
Platform.SetRenderer(cell.View, view);
cell.View.IsPlatformEnabled = true;
var c = new ViewCellContainer(context, view, cell, ParentView, unevenRows, rowHeight);
Performance.Stop();
return c;
}