本文整理汇总了C#中Android.OS.Handler类的典型用法代码示例。如果您正苦于以下问题:C# Handler类的具体用法?C# Handler怎么用?C# Handler使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Handler类属于Android.OS命名空间,在下文中一共展示了Handler类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnCreateView
public override View OnCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState)
{
View rootView = inflater.Inflate(Resource.Layout.user_detail, container, false);
if (_user != null) {
((TextView)rootView.FindViewById (Resource.Id.user_name)).Text = $"{_user.FirstName} {_user.LastName}";
((TextView)rootView.FindViewById (Resource.Id.mail_header)).Text = $"[Email]";
((TextView)rootView.FindViewById (Resource.Id.user_mail)).Text = _user.Email;
((TextView)rootView.FindViewById (Resource.Id.phone_header)).Text = $"[Telefon]";
((TextView)rootView.FindViewById (Resource.Id.user_phone)).Text = _user.Phone;
((TextView)rootView.FindViewById (Resource.Id.cell_header)).Text = $"[Mobil]";
((TextView)rootView.FindViewById (Resource.Id.user_cell)).Text = _user.Cell;
var imageView = (ImageView)rootView.FindViewById (Resource.Id.user_image);
Handler handler = new Handler (Context.MainLooper);
Task.Run (() => {
var imageBitmap = ((ImageService)ServiceLocator.Current.GetInstance<ImageService>()).GetUserPicture(_user);
Runnable runnable = new Runnable (() => {
imageView.SetImageBitmap (imageBitmap);
});
handler.Post (runnable);
});
}
return rootView;
}
示例2: WidgetProvider
public WidgetProvider()
{
// Start the worker thread
workerThread = new HandlerThread (ThreadWorkerName);
workerThread.Start();
workerQueue = new Handler (workerThread.Looper);
}
示例3: BeginGeofencing
public void BeginGeofencing(object sender, EventArgs eventArgs)
{
if (!apiClient.IsConnected) {
var myHandler = new Handler ();
myHandler.Post (() => {
Android.Widget.Toast.MakeText (this, "Google API Not Connected. Try Again.", Android.Widget.ToastLength.Long).Show ();
});
return;
}
try {
if (connectedGeofences.Count >= 1) {
LocationServices.GeofencingApi.AddGeofences(apiClient, getGeofencingRequest(), getGeofencePendingIntent()).SetResultCallback(this);
string geofenceAnnounce = "Geofences Active At The Following Locations:\n";
foreach (ROMPGeofence geofName in connectedGeofences) {
geofenceAnnounce += geofName.Id + "\n";
}
var myHandler = new Handler ();
myHandler.Post (() => {
Android.Widget.Toast.MakeText (this, geofenceAnnounce, Android.Widget.ToastLength.Long).Show ();
});
FindViewById<Button>(Resource.Id.btnBegin).Visibility = ViewStates.Invisible;
FindViewById<TextView>(Resource.Id.lblConfirm).SetText("A record that you have checked-in will be made in the log of your education activity for this ROMP rotation when this device enters a 1km radius surrounding the facility of your ROMP rotation.", TextView.BufferType.Normal);
geofenceRequestIntent = PendingIntent.GetService (this, 0,
new Intent (this, Java.Lang.Class.FromType (typeof(GeofenceTransitionsIntentService))),
PendingIntentFlags.UpdateCurrent);
} else {
FindViewById<Button>(Resource.Id.btnBegin).Visibility = ViewStates.Invisible;
FindViewById<TextView>(Resource.Id.lblConfirm).SetText("No Rotations Available, Please Try Within Your Scheduled Rotation Dates", TextView.BufferType.Normal);
}
} catch (SecurityException securityEx) {
logSecurityException (securityEx);
}
}
示例4: SkiaView
public SkiaView(Activity context) : base(context)
{
_context = context;
SkiaPlatform.Initialize();
Holder.AddCallback(this);
_handler = new Handler(context.MainLooper);
}
示例5: OnCreate
protected override void OnCreate(Bundle savedInstanceState) {
base.OnCreate(savedInstanceState);
var pos = 0;
if (Intent.Extras != null)
pos = Intent.Extras.GetInt("pos");
var birds = Resources.GetStringArray(Resource.Array.birds);
var imgs = Resources.ObtainTypedArray(Resource.Array.birds_img);
var resId = imgs.GetResourceId(pos, -1);
Title = birds[pos];
Window.RequestFeature(WindowFeatures.ActionBarOverlay);
var color = new ColorDrawable(Color.Black);
color.SetAlpha(128);
ActionBar.SetBackgroundDrawable(color);
ActionBar.SetDisplayHomeAsUpEnabled(true);
_handler = new Handler();
var imageView = new ImageView(this);
imageView.SetScaleType(ImageView.ScaleType.CenterInside);
imageView.SetImageResource(resId);
imageView.Click += (sender, args) =>
{
ActionBar.Show();
HideActionBarDelayed(_handler);
};
SetContentView(imageView);
Window.SetBackgroundDrawableResource(Android.Resource.Color.BackgroundDark);
}
示例6: Peer_PeerConnected
private void Peer_PeerConnected (object sender, PeerConnectedEventArgs args)
{
using (var h = new Handler (Looper.MainLooper))
h.Post (() => {
textView.Text = args.PeerId;
});
}
示例7: OnCreate
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate (savedInstanceState);
mPreview = new Preview (this);
RequestWindowFeature(WindowFeatures.NoTitle);
Window.AddFlags (WindowManagerFlags.Fullscreen);
SetContentView (Resource.Layout.CustomCameraLayout);
FrameLayout preview = (FrameLayout)FindViewById (Resource.Id.camera_preview);
preview.AddView (mPreview);
mPicture = new PictureCallback ();
//////////////////////////////////////
Handler mHandler = new Handler ();///
////////////////////////////////////
Button captureButton = FindViewById<Button> (Resource.Id.button_capture);
captureButton.Click += (sender, e) => {
System.Console.WriteLine("About to call take picture");
mCamera.TakePicture(null, null, mPicture);
System.Console.WriteLine("After TakePicture");
Toast.MakeText(this, "Saving picture...", ToastLength.Long).Show();
mHandler.PostDelayed(launchConfirmActivity,1000); //ideally this would be done through asynchronous methods, but this temporary fix will have to do for now
};
View controllers = FindViewById<RelativeLayout> (Resource.Id.CameraControls_layout);
controllers.BringToFront();
}
示例8: OnLayout
protected override void OnLayout (bool changed, int l, int t, int r, int b)
{
using (var h = new Handler (Looper.MainLooper)) {
h.Post (() => {
double width = base.Context.FromPixels ((double)(r - l));
double height = base.Context.FromPixels ((double)(b - t));
var size = new Size (width, height);
var msw = MeasureSpec.MakeMeasureSpec (r - l, MeasureSpecMode.Exactly);
var msh = MeasureSpec.MakeMeasureSpec (b - t, MeasureSpecMode.Exactly);
_nativeView.Measure (msw, msh);
_nativeView.Layout (0, 0, r - l, b - t);
// if (size != _previousSize) {
var layout = _viewCell.View as Layout<Xamarin.Forms.View>;
if (layout != null) {
layout.Layout (new Rectangle (0, 0, width, height));
layout.ForceLayout ();
FixChildLayouts (layout);
_isLaidOut = true;
}
_previousSize = size;
});
}
// }
}
示例9: RunOnMainThread
protected void RunOnMainThread(Action action)
{
Handler handler = new Handler(Looper.MainLooper);
handler.Post(action);
handler.Dispose();
handler = null;
}
示例10: OnMarkerClick
//
// Marker related listeners.
//
public bool OnMarkerClick(Marker marker)
{
// This causes the marker at Perth to bounce into position when it is clicked.
if (marker.Equals(mPerth)) {
Handler handler = new Handler ();
long start = SystemClock.UptimeMillis ();
Projection proj = mMap.Projection;
Point startPoint = proj.ToScreenLocation(PERTH);
startPoint.Offset(0, -100);
LatLng startLatLng = proj.FromScreenLocation(startPoint);
long duration = 1500;
IInterpolator interpolator = new BounceInterpolator();
Runnable run = null;
run = new Runnable (delegate {
long elapsed = SystemClock.UptimeMillis () - start;
float t = interpolator.GetInterpolation ((float) elapsed / duration);
double lng = t * PERTH.Longitude + (1 - t) * startLatLng.Longitude;
double lat = t * PERTH.Latitude + (1 - t) * startLatLng.Latitude;
marker.Position = (new LatLng(lat, lng));
if (t < 1.0) {
// Post again 16ms later.
handler.PostDelayed(run, 16);
}
});
handler.Post(run);
}
// We return false to indicate that we have not consumed the event and that we wish
// for the default behavior to occur (which is for the camera to move such that the
// marker is centered and for the marker's info window to open, if it has one).
return false;
}
示例11: OnCreate
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
// Set our view from the "main" layout resource
SetContentView(Resource.Layout.Main);
// Get our button from the layout resource,
// and attach an event to it
Button button = FindViewById<Button>(Resource.Id.button1);
button.Click += button_Click;
Button button2 = FindViewById<Button>(Resource.Id.button2);
button2.Click += button2_Click;
LogOut.Action += LogOut_Action;
MessHander = new Handler(Msg =>
{
FindViewById<TextView>(Resource.Id.textView1).Append(Msg.Obj.ToString() + "\n");
});
client = new ClientInfo(GetString(Resource.String.ServerIP), int.Parse(GetString(Resource.String.ServerPort)), int.Parse(GetString(Resource.String.ServerRegPort)), int.Parse(GetString(Resource.String.MinPort)), int.Parse(GetString(Resource.String.MaxPort)), int.Parse(GetString(Resource.String.ResCount)), GetString(Resource.String.MAC));
client.ConToServer();
client.ClientDataIn += client_ClientDataIn;
client.ClientConnToMe += client_ClientConnToMe;
client.ClientDiscon += client_ClientDiscon;
}
示例12: OnClick
public void OnClick(View v)
{
Handler h = new Handler();
h.Post(() => {
this.Img.StartAnimation(this.AniSet);
});
}
示例13: OnCreate
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
SetContentView(Resource.Layout.Main);
progress1 = FindViewById<CircleProgressBar>(Resource.Id.progress1);
progress2 = FindViewById<CircleProgressBar>(Resource.Id.progress2);
progressWithArrow = FindViewById<CircleProgressBar>(Resource.Id.progressWithArrow);
progressWithoutBg = FindViewById<CircleProgressBar>(Resource.Id.progressWithoutBg);
progress2.SetColorSchemeResources(Android.Resource.Color.HoloGreenLight);
progressWithArrow.SetColorSchemeResources(Android.Resource.Color.HoloOrangeLight);
progressWithoutBg.SetColorSchemeResources(Android.Resource.Color.HoloRedLight);
handler = new Handler();
for (int i = 0; i < 10; i++)
{
int finalI = i;
handler.PostDelayed(() =>
{
if (finalI * 10 >= 90)
{
progress2.Visibility = ViewStates.Invisible;
}
else
{
progress2.Progress = finalI * 10;
}
}, 1000 * (i + 1));
}
}
示例14: OnCreate
public override void OnCreate()
{
base.OnCreate();
Log.Info(TAG, "OnCreate: the service is initializing.");
timestamper = new UtcTimestamper();
handler = new Handler();
// This Action is only for demonstration purposes.
runnable = new Action(() =>
{
if (timestamper == null)
{
Log.Wtf(TAG, "Why isn't there a Timestamper initialized?");
}
else
{
string msg = timestamper.GetFormattedTimestamp();
Log.Debug(TAG, msg);
Intent i = new Intent(Constants.NOTIFICATION_BROADCAST_ACTION);
i.PutExtra(Constants.BROADCAST_MESSAGE_KEY, msg);
Android.Support.V4.Content.LocalBroadcastManager.GetInstance(this).SendBroadcast(i);
handler.PostDelayed(runnable, Constants.DELAY_BETWEEN_LOG_MESSAGES);
}
});
}
示例15: BluetoothManager
//--------------------------------------------------------------
// CONSTRUCTORS
//--------------------------------------------------------------
public BluetoothManager()
{
_deviceAddress = string.Empty;
_handler = new MyHandler ();
_bluetoothAdapter = BluetoothAdapter.DefaultAdapter;
_state = StateEnum.None;
}