Can anyone point me to a Xamarin.forms sample that utilises AndHud for Android and BTProgressHud for iOS (or anything similar)?
I know there is the ACR-Xamarin-Forms example here https://github.com/aritchie/acr-xamarin-forms, but it is way too complicated and completely over my head.
Surely there is a more simple easy to understand implementation, but if not some sort of guidance on how to get started on implementing it (for a C# and Xamarin newbie)
Thanks in advance
This is how I've done it for iOS. All you should need to do for Android is create an implementation of IHud that using AndHud instead of BTProgressHud.
First, create an interface in the shared project
public interface IHud
{
void Show();
void Show(string message);
void Dismiss();
}
Next, in the iOS project, create an implementation of IHud using BTProgressHud component:
[assembly: Dependency(typeof(Hud))]
namespace project.iOS
{
public class Hud : IHud
{
public Hud ()
{
}
public void Show() {
BTProgressHUD.Show ();
}
public void Show(string message) {
BTProgressHUD.Show (message);
}
public void Dismiss() {
BTProgressHUD.Dismiss ();
}
}
}
Finally, to utilize this from Forms code, just do
var hud = DependencyService.Get<IHud> ();
hud.Show ("Loading Vehicles");
// tasks...
hud.Dismiss ();
My answer, which is quite similar to #jason's can be found here:
Loading Icon for layout screen Xamarin android
Related
I'm a Unity tools developer and i want to put a GUILayout.Label(" title ") inside a FoldoutHeaderGroup so i did that :
using UnityEditor;
using UnityEngine;
public class tesdtEditor : EditorWindow
{
private bool showWindowFoldOut;
[MenuItem("test")]
public static void ShowWindow()
{
EditorWindow.GetWindow(typeof(tesdtEditor));
}
public void OnGUI()
{
showWindowFoldOut = EditorGUILayout.BeginFoldoutHeaderGroup(showWindowFoldOut, "foldout Name");
GUILayout.Label("title");
EditorGUILayout.EndFoldoutHeaderGroup();
}
}
But it's not in my FoldoutHeaderGroup (Screen of the window)
I can't see where I'm mistaken, can someone guide me through ?
You still need to check the
if(showWindowFoldOut)
{
EditorGUI.indentLevel++;
GUILayout.Label("title");
EditorGUI.indentLevel--;
}
See example in EditorGUILayout.BeginFoldoutHeaderGroup.
Tbh besides the different styling I didn't understand so far what the difference is between that and a simple EditorGUILayout.Foldout.
Is there any way to listen to notificstions(read their text) shown in notificstion bar in Xamarin?
I know that in AndroidStudio, we can use NotificationListenerService, but I can not find any Xamarin alternative.
Real example:
I recieve a Whatsapp message and get notified, I want my app to check if the message was sent by Emily- if so, do something...
Thanks for help and replies
Xamarin.Android has a framework wrapper for Android.Service.Notification.NotificationListenerService.
[Register ("android/service/notification/NotificationListenerService", DoNotGenerateAcw = true, ApiSince = 18)]
public abstract class NotificationListenerService : Service
{
~~~
}
Just as in Java, it is an abstract class that you need to implement.
public class MyNotificationListenerService : NotificationListenerService
{
public override void OnCreate()
{
base.OnCreate();
}
public override void OnNotificationPosted(StatusBarNotification sbn)
{
~~~~
}
public override void OnNotificationRemoved(StatusBarNotification sbn)
{
~~~~
}
}
I'm 12 hours into using Xamarin, and have a beginner blocker while working on a Xamarin / c# project for iOS 7.
This is how I though the view controller should call kickOff (but it doesnt work):
using iOS;
...
public void ViewDidLoad () {
base.ViewDidLoad ();
kickOff ();
}
exampleClass.cs:
namespace iOS
{
public class foo
{
public static void kickOff (){
Console.WriteLine("Success!");
}
}
What am I missing? Thanks!
You never point to the class foo. You need to tell it where to look for the method kickOff()
The following should work:
foo.kickOff();
Note
Your question doesn't say what doens't work, but I'm assuming it's a compiler error about kickOff not being a valid method
Hello i need to prevent my popover from dismissing when clicking outside the box.
I found some answers but all in objective C and i cant understand it very well.
Stop UIPopover from dismissing automatically
Anyone knows how to do that in xamarin?
UIKit's [UIPopoverControllerDelegate popoverControllerShouldDismissPopover:] translates to UIPopoverControllerDelegate.ShouldDismiss in MonoTouch.
popover.Delegate = new MyPopoverDelegate();
...
class MyPopoverDelegate : UIPopoverControllerDelegate
{
public override bool ShouldDismiss (UIPopoverController popoverController)
{
return false;
}
}
I'm not completely positive, but I believe you can also just have your main class implement the IUIPopoverControllerDelegate interface and add ShouldDismiss directly to it:
popover.Delegate = this;
...
public override bool ShouldDismiss (UIPopoverController popoverController)
{
return false;
}
Google is flooded with Unity3D & XNA resources. It is quite difficult to search for anything dealing with C# without the results being overwhelmingly Unity or XNA based. To even find good tutorials, I had to find a book on amazon and then google the author with -XNA -Unity, lol.
My C++ code is organized nicely with each separate major class being its own file, in an organized directory.
Game.cpp
Init.cpp
Render.cpp
Update.cpp
Game.cpp, being main(), where my game runs and calls Init, Render, and Update.
class Game
{
public:
Game();
private:
void Init();
void Update(sf::Time deltaTime);
void Render();
sf::RenderWindow mWindow;
};
int main()
{
Init();
while (mWindow.isOpen())
{
Update(TimePerFrame);
Render();
}
}
And of course, Init.cpp
#include "Game.hpp"
void Game::Init()
{
mWindow.setVerticalSyncEnabled(true);
}
Now, I have the C# bindings for SFML and switched from Code::Blocks to VS2012. I've been working with C++ for so long that I am having some trouble with C#. I went through some tutorials to refresh myself with the syntax, but there is something I'm still not remembering. Obviously, this is a dumb question. However, google is not very much help due to how overwhelmingly swarmed C# is with Unity & XNA results, and I just can't remember how to do this right.
I want to have the same separate files,
Game.cs
Init.cs
Update.cs
Render.cs
However, I can't even get it to function in a single class.
Game.cs
class Game
{
public void Main()
{
// Create the main window
RenderWindow mWindow = new RenderWindow(new VideoMode(1200, 1200), "SevenBlack");
mWindow.Closed += new EventHandler(OnClose);
Color windowColor = new Color(0, 0, 0);
//Initialize Game
Init();
while (mWindow.IsOpen())
{
Update(TimePerFrame);
}
Render();
}
}
private void Init()
{
mWindow.setVerticalSyncEnabled(true);
}
private void Update(long dt)
{
}
private void Render()
{
mWindow.Clear(windowColor);
mWindow.Display();
}
}
I get "The name 'mWindow' does not exist in the current context.
private void Game::Init()
{
mWindow.setVerticalSyncEnabled(true);
}
Does not work either, since this is C#.
mWindow is not declared as a class level variable, so its only scope is in main. Do this to allow the variable to be seen to the entire class.
class Game
{
private RenderWindow mWindow;
public void Main()
{
// Create the main window
mWindow = new RenderWindow(new VideoMode(1200, 1200), "SevenBlack");
...