我是Xamarin Android C#开发的新手,还在阅读教程..而且我很难在一个应用程序中合并两个活动..虽然我按照教程中的所有说明我想知道为什么会发生这种情况..我希望有人可以以某种方式帮助我...
我有2个活动:"FirstActivity"和"SecondActity"
我想要的是将它安装为一个应用程序,但输出是这样的:
2 "Android Two"应用程序..
我熟悉"可达性"类来检查是否存在互联网连接:https: //github.com/xamarin/monotouch-samples/blob/master/ReachabilitySample/reachability.cs
我现在想知道在网络状态发生变化时是否有任何方法可以获得通知?假设在没有互联网的情况下加载我的收藏品.图像不会被加载.如果iPad突然再次连接互联网,我想再次触发下载.
在reachability类中,我看到以下代码:
public static event EventHandler ReachabilityChanged;
static void OnChange (NetworkReachabilityFlags flags)
{
var h = ReachabilityChanged;
if (h != null)
h (null, EventArgs.Empty);
}
Run Code Online (Sandbox Code Playgroud)
但是,如果我在"OnChange"方法中设置断点,则在关闭Wifi时不会调用它.
有任何想法吗?
问候,马特
我正在尝试使用CI和Xamarin Test Cloud来使用Visual Studio Online进行自动CI +执行测试场景.
在创建新的Xamarin Android构建定义时,它要求为Devices输入一个值,引用为
设备字符串由Xamarin Test Cloud生成.它可以作为Test Cloud测试运行的--devices命令行参数的值找到.
任何想法如何从这里得到这个字符串?我正在使用UiTest并将测试从Visual Studio上传到Xamarin测试云 - >测试项目 - >右键单击 - >在测试云中运行
帮助表示赞赏.
谢谢ST
我的图像按钮有问题我希望我的功能Categorie_Onclick可以看到按钮被点击.我尝试添加标签,但它不起作用.有没有办法做到这一点?
XAML:
<!-- Button1 -->
<Image
x:Name="CityGuideButton1"
Source="shopping_gray.png"
Aspect="Fill"
HorizontalOptions="FillAndExpand"
VerticalOptions ="FillAndExpand"
Tag="01">
<Image.GestureRecognizers>
<TapGestureRecognizer
Tapped="Categorie_Onclick"
NumberOfTapsRequired="1"/>
</Image.GestureRecognizers>
</Image>
<!-- Button2 -->
<Image
x:Name="CityGuideButton2"
Source="secrets.png"
Aspect="Fill"
HorizontalOptions="FillAndExpand"
VerticalOptions ="FillAndExpand"
Tag="02">
<Image.GestureRecognizers>
<TapGestureRecognizer
Tapped="Categorie_Onclick"
NumberOfTapsRequired="1"/>
</Image.GestureRecognizers>
Run Code Online (Sandbox Code Playgroud)
按钮处理程序
private async void Categorie_Onclick(Object sender, EventArgs args)
{
Image cmd = sender as Image;
string txt = TapGestureRecognizer.tag.ToString();
await Navigation.PushAsync(new CategoriePage());
}
Run Code Online (Sandbox Code Playgroud) 在Laravel中,如何在链接到路径时使用html-tags HTML::link_to_route()?
我的例子:
<li>
{{ HTML::link_to_route( "books_new", "New Book" ) }}
</li>
Run Code Online (Sandbox Code Playgroud)
我想做什么:
<li>
{{ HTML::link_to_route(
"books_new",
"<span class='icon-book'></span>New Book"
) }}
</li>
Run Code Online (Sandbox Code Playgroud) 注意:我甚至在提出问题之前就找到了解决问题的方法,但我仍然想知道为什么它会像这样.
我在做一个平常xamarin.iOS应用程序,使用async/await,Mvvm,...没有在技术方面看中.
我发现以下代码(使用a method group)无效:
ViewModel.PropertyChanged += (sender, e) => {
if (e.PropertyName != "MyProperty")
return;
InvokeOnMainThread (tableViewController.TableView.ReloadData);
};
Run Code Online (Sandbox Code Playgroud)
如果我打开一个断点InvokeOnMainThread,我可以看到异常:

但是同样的代码可以lambda expression正常工作.
ViewModel.PropertyChanged += (sender, e) => {
if (e.PropertyName != "MyProperty")
return;
InvokeOnMainThread (() => tableViewController.TableView.ReloadData ());
};
Run Code Online (Sandbox Code Playgroud)
我的一部分怀疑是一个错误,另一部分已经归咎于我的无知.谁知道哪个部分是对的?
我得到TinyIOC无法解决类型异常.我使用Xamarin studio for ipad开发了我的应用程序.在模拟器中它工作正常.但在部署ipad时,我遇到了错误.
TinyIoC.TinyIoCResolutionException:无法解析类型:IOSLoginViewModel ---> System.Exception:无法解析类型:IOSLoginViewModel ---> System.Exception:无法解析类型:
private IEnumerable<ConstructorInfo> GetTypeConstructors(Type type)
{
//#if NETFX_CORE
// return type.GetTypeInfo().DeclaredConstructors.OrderByDescending(ctor => ctor.GetParameters().Count());
//#else
return type.GetConstructors().OrderByDescending(ctor => ctor.GetParameters().Count());
//#endif
}
Run Code Online (Sandbox Code Playgroud)
上面的方法是在模拟器上返回值,但对于ipad,它给出null.
我用过的代码行是
var tContainer = TinyIoC.TinyIoCContainer.Current;
tContainer.Register<IOnlineAuthenticationService, Framework.OnlineProvider.AuthenticationService>().AsMultiInstance();
DataContext = TinyIoC.TinyIoCContainer.Current.Resolve<IOSLoginViewModel>();
Run Code Online (Sandbox Code Playgroud)
IOS构建选项我已经尝试了所有,链接 - SDK,ALL,No但仍然是相同的错误.
我能够为我的Objective-C静态库成功创建dll文件.但是当我尝试从Xamarin.iOS应用程序和编译中引用该dll时,它给了我很多错误,比如......
错误MT5210:本机链接失败,未定义符号:_AudioFileClose.请验证是否已引用所有必需的框架并且本机库已正确链接.(MT5210)
错误MT5210:本机链接失败,未定义符号:std :: ios_base :: Init :: Init().请验证是否已引用所有必需的框架并且本机库已正确链接.(MT5210)
错误MT5202:本机链接失败.请查看构建日志.(MT5202)
在此之后,我尝试使用Addtional mtouch Arguments链接我的.a库.添加这些参数后,我收到了新的错误.
无法解析命令行参数:无法捆绑未注册的选项'-o'.
有人可以帮我解决这个问题.
我对Xamarin完全不熟悉,所以请耐心等待!不知何故,Xamarin为我的所有按钮添加了一个神秘的边缘,我不知道如何摆脱它.
这是我的代码:
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="RockStamp.CameraSearch_Scan">
<StackLayout Orientation="Vertical" Padding="0" Spacing="0">
<StackLayout Orientation="Horizontal" Padding="0" Spacing="0">
<Button Text="Test" HeightRequest="50" WidthRequest="60" TextColor="#333333" x:Name="btnBack" VerticalOptions="Center" HorizontalOptions="Start" ></Button>
<Label Text="Scan a..." FontSize="20" FontAttributes="Bold" BackgroundColor="{StaticResource BlueBackColor}" TextColor="White" VerticalOptions="Start" HorizontalOptions="FillAndExpand" />
</StackLayout>
<Label Text="Steady now, we try to detect your..." FontSize="16" VerticalOptions="Start" HorizontalOptions="Start" />
<!-- Camera Placeholder -->
<BoxView HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" BackgroundColor="#eeeeee" ></BoxView>
<StackLayout Orientation="Horizontal" Padding="0" Spacing="0">
<Button Text="Cancel" TextColor="#333333" x:Name="btnCancel" VerticalOptions="Center" HorizontalOptions="FillAndExpand" ></Button>
<Button Text="Scan now!" TextColor="#333333" x:Name="btnScan" VerticalOptions="Center" HorizontalOptions="FillAndExpand" ></Button>
</StackLayout>
</StackLayout >
</ContentPage>
Run Code Online (Sandbox Code Playgroud)
这是一张图片: …
我正在尝试在 Xamarin Forms 中实现本地推送通知。我正在使用 DependencyService 来获取通知的 Android 实现。
这是我用来在特定时间推送通知的代码:
public void SetNotification(DateTime notificationDate, TimeSpan notificationTime)
{
long dateInMilli = (long)(notificationDate.Add(notificationTime) - DateTime.MinValue).TotalMilliseconds;
Notification.Builder builder = new Notification.Builder(Xamarin.Forms.Forms.Context)
.SetContentTitle("Test Notification")
.SetContentText("Notification from Xamarin Forms")
.SetSmallIcon(Resource.Drawable.icon)
.SetDefaults(NotificationDefaults.Sound)
.SetWhen(dateInMilli);
Notification notification = builder.Build();
NotificationManager notificationManager =
(NotificationManager)Forms.Context.GetSystemService(Context.NotificationService);
const int notificationId = 0;
notificationManager.Notify(notificationId, notification);
}
Run Code Online (Sandbox Code Playgroud)
问题是,通知不是按照设置的日期和时间立即显示的SetWhen(dateInMilli)。