Tag: xamarin

点击列表视图项目上的手势

我在点击列表视图中的项目后尝试打开另一个视图。 我尝试添加TapGestureRegonizer ,甚至添加带网格的ViewCell等。这些似乎都不起作用。 我已经为标签添加了一个轻击手势,这似乎有效,但同样不适用于列表视图项目。 这看起来像列表视图这样的简单问题,但似乎没有内置的function。 Xaml: 背后的代码: var listviewgesture = new TapGestureRecognizer(); listviewgesture.SetBinding(TapGestureRecognizer.CommandProperty,”LoadRoutePage”); dataList.GestureRecognizers.Add(listviewgesture); 视图模型: public ICommand LoadRoutePage { get; protected set; } public DriverDashboardViewModel(INavigation navigation,MessagDatabase database) { this._database = database; this.Navigation = navigation; this.LoadNotifications = new Command(async () => await OpenNotificationsPage()); this.LoadRoutePage = new Command(async () => await OpenRoutePage()); } public async Task OpenRoutePage() […]

语音识别android应用程序

当我按下发言按钮并在列表视图上打印结果时,我的应用程序识别语音,当我点击结果时,我想要将它打印在烤面包上…. 问题是,当我再次点击按钮时,它会打印新文本和旧文本,例如我第一次得到:(不,现在,知道)我点击否,它显示“现在”,第二次给(谷歌,好,谷歌)我按好,它打印“现在”然后“好” 我想它记得整个listview,请你帮我解决这个问题,这是代码: if (resultCode == Result.Ok) { IList matches = data.GetStringArrayListExtra(RecognizerIntent.ExtraResults); voice_list.Adapter = new ArrayAdapter(this, Android.Resource.Layout.SimpleListItem1, matches); voice_list.ItemClick += delegate(object sender, Android.Widget.AdapterView.ItemClickEventArgs e) { var t = matches[e.Position]; string TextToTranslate = t.ToString(); Android.Widget.Toast.MakeText(this, TextToTranslate , Android.Widget.ToastLength.Long).Show(); }; }

每隔几秒自动刷新或更新内容页面

我正在使用Xamarin.forms ( PCL ),我需要每隔几秒刷新/更新内容页面及其数据。 在viewmodel从API检索数据。 是否有任何方法或处理程序可以定期在page.xaml.cs定期调用Get Api ,如: methodRunPeriodically() { userdata = await UserService.GetUserasync(_UserViewModel.EmployeeId); }

Xamarin表示Android MapRenderer

我为Xamarin iOS成功创建了一个ViewRenderer,现在我正在尝试为Android实现一个Renderer,这里是我需要在Android中实现的Map: public class MapViewModel : Map { public static readonly BindableProperty LocationsProperty = BindableProperty.Create<MapViewModel, List>(x => x.Locations, new List()); public static readonly BindableProperty PinTappedCommandProperty = BindableProperty.Create(x => x.PinTapped, null); public MapViewModel(List locations) { Locations = locations; PinTapped = new Command(async (x) => { //await Navigation.PopModalAsync(); var info = new InformationView((Branch)x); await Navigation.PushAsync(info); }); } […]

在跨平台xamarin项目(ios和android)中使用c#从查询列表中检索数据时面临参数exception错误

在跨平台xamarin项目(ios和android)中使用c#从查询列表中检索数据时遇到参数exception错误。 我试图从azure色(云)上的简单表中检索数据。 这是我的代码 try { var client = new MobileServiceClient(“https://eg.azurewebsites.net”); IMobileServiceTable regTable = client.GetTable(); Reg reg = new Reg(); string imail = uemail2.Text.ToString(); // This query to seach email var email1 = await regTable .Where(Reg => Reg.email.ToString() == imail) .Select(email => email.Text.ToString()) .ToListAsync(); notice3.Text = email1[0].ToString(); } catch (ArgumentException ex) { notice.Text = “Arguments Error” […]

Xamarin仅在设备上丢失了自定义objc类别(无法识别的选择器发送到实例)

情况: 我有一个在我的objc静态库中定义的自定义类别: @implementation UIViewController (Colorful) -(void)changeColor:(UIColor *)color { self.view.backgroundColor = color; } @end 它绑定到Xamarin项目: [Category, BaseType(typeof(UIViewController))] interface UIViewController_Colorful { [Export (“changeColor:”)] void ChangeColor(UIColor color); } 此类别用于以下代码: public override bool FinishedLaunching (UIApplication app, NSDictionary options) { window = new UIWindow (UIScreen.MainScreen.Bounds); UIViewController vc = new UIViewController (); vc.ChangeColor (UIColor.Red); window.RootViewController = vc; window.MakeKeyAndVisible (); return true; […]

使用和现有的.DLL文件构建Xamarin组件

我已经有一个使用.NET framework 4.0开发的.dll文件。 我想使用这个dll文件来构建一个Xamarin组件。 我正在按照指南https://components.xamarin.com/guidelines,但没有任何工作方式。 总是得到以下错误: Blockquote Unhandled Exception:Xamarin.Components.Packaging.InvalidPackageException:找不到lib directo ry,组件包中没有包含二进制文件。 在Xamarin.Components.Packaging.ComponentPackage.PopulateAvailableFrameworks()[0x00000] in:0中的Xamarin.Components.Packaging.ComponentPackage.Init()[0x00000] in:0 at Xamarin.Components.Packaging.ComponentPackage..ctor(System。字符串文件)[0 x00000] in:0 at Xamarin.Components.Packaging.Creation.PackageCreator.ValidatePackage(Syste m.String packagePath)[0x00000] in:0 at Xamarin.Components.CreateManuallyCommandHandler.Invoke(System.String [] arg s)[0x00000] in:0 [错误]致命未处理exception:Xamarin.Components.Packaging.InvalidPackageEx ception:找不到lib目录,组件包中没有包含二进制文件。 在Xamarin.Components.Packaging.ComponentPackage.PopulateAvailableFrameworks()[0x00000] in:0中的Xamarin.Components.Packaging.ComponentPackage.Init()[0x00000] in:0 at Xamarin.Components.Packaging.ComponentPackage..ctor(System。字符串文件)[0 x00000] in:0 at Xamarin.Components.Packaging.Creation.PackageCreator.ValidatePackage(Syste m.String packagePath)[0x00000] in:0 at Xamarin.Components.CreateManuallyCommandHandler.Invoke(System.String [] arg s)[0x00000] in:0 rake aborted! 命令失败,状态为(1):[mono xamarin-component / xamarin-component […]

使用C#从Xamarin Studio中的ListView获取EditText控件

我正在使用带有C#的Xamarin Studio。 我在listview适配器中添加了EditText控件。 此列表是动态填充的。 现在我希望获得活动类中所有EditText的值。 我怎么能做到这一点? `public class PRDeptHeadApprovalDetailAdapter:BaseAdapter {List items; 活动背景; public PRDeptHeadApprovalDetailAdapter(Activity context, List items) : base() { this.context = context; this.items = items; } public override long GetItemId(int position) { return position; } public override string this[int position] { get { return items[position].ToString(); } } public override int Count { get { […]

地理定位不适用于iOS PCL Xamarin表单

我试图通过此示例https://github.com/XLabs/Xamarin-Forms-Labs/wiki/Geolocator获取设备位置。 这适用于模拟器,但在iPad Air上不起作用。 我的info.plist文件包含位置的所有必要密钥。,NSLocationUsageDescription和NSLocationWhenInUseUsageDescription 在代码中 if (this.manager.RespondsToSelector(new Selector(“requestWhenInUseAuthorization”))) { this.manager.RequestWhenInUseAuthorization(); } 使用Geolocator对象的一段代码.. IGeolocator geolocator = null; geolocator = DependencyService.Get(); if (geolocator != null) { if (geolocator.IsGeolocationEnabled) { try { if (!geolocator.IsListening) geolocator.StartListening(1000, 1000); var task = await geolocator.GetPositionAsync(10000, CancellationToken.None); if(task != null) { this.Position = task; } 但是LocationUpdated事件永远不会发生…… 设备上的位置已开启。 如果有人有类似的问题…….请帮助…..一旦,这项工作在模拟器上。 我在iPad Air上使用VS 2013,Xamarin 3.7,Xamarin.iOS 8.4,iOS […]

oData中的集合名称列表

我很困惑如何从以下odata服务获取集合名称列表http://services.odata.org/V4/Northwind/Northwind.svc/ 我只想获得服务中所有可用集合名称的列表然后我想让用户选择要查看其信息的集合,然后显示该集合中的项目 例如,以下行访问Customers集合。 var customers = client.For(“Customers”).FindEntriesAsync(); 我可以按如下方式访问每个集合的内部。 static void Main(string[] args) { var client = new ODataClient(“services.odata.org/Northwind/Northwind.svc/”); var customers = client.For(“Customers”).FindEntriesAsync(); foreach (var customer in customers) { Console.WriteLine(customer[“CustomerID”]); } }