我需要四舍五入到小数位数的货币.
都
Math.round(num*Math.pow(10,2))/Math.pow(10,2)
Run Code Online (Sandbox Code Playgroud)
和
Math.round(num*Math.pow(10,2))/Math.pow(10,2)
Run Code Online (Sandbox Code Playgroud)
工作,除了它削减任何尾随零关闭,所以我得到29.9而不是29.90.
围绕这个最好的方法是什么?
我从这里使用Xamarin.Forms Camera示例 - https://github.com/XForms/Xamarin-Forms-Labs-Samples/tree/master/XF.Labs.CameraSample我可以选择或拍照.
private async Task SelectPicture()
{
mediaPicker = DependencyService.Get<IMediaPicker>();
imageSource = null;
var mediaFile = await mediaPicker.SelectPhotoAsync(new CameraMediaStorageOptions
{
DefaultCamera = CameraDevice.Front,
MaxPixelDimension = 400
});
imageSource = ImageSource.FromStream(() => mediaFile.Source);
img.Source = imageSource;
}
private async Task TakePicture()
{
mediaPicker = DependencyService.Get<IMediaPicker>();
imageSource = null;
var mediaFile = await mediaPicker.TakePhotoAsync(new CameraMediaStorageOptions
{
DefaultCamera = CameraDevice.Front,
MaxPixelDimension = 400
});
imageSource = ImageSource.FromStream(() => mediaFile.Source);
img.Source = imageSource;
}
Run Code Online (Sandbox Code Playgroud)
图像的代码很简单
img = new Image
{
BackgroundColor …Run Code Online (Sandbox Code Playgroud) 我有一个页面,我想在顶部始终查看标题,按钮始终在底部的视图中.中间的内容是可滚动的.
我认为这可以通过以下方式轻松实现:
StackLayout outer = new StackLayout();
StackLayout inner = new StackLayout();//with all of the content added
ScrollView scroll = new ScrollView();
outer.Children.Add(headerLabel);//non-scrolling
scroll.Content = inner;
outer.Children.Add(scroll); //scrolling
outer.Children.Add(button); //non-scrolling
Run Code Online (Sandbox Code Playgroud)
headerLabel和按钮保持在正确位置,但内容向上滚动到页面顶部,在headerLabel的顶部(但在底部按钮的下方/下方).
我很肯定它工作正常,但我不记得改变了什么.
有没有人知道为什么会发生这种情况?
任何人都可以指向一个Xamarin.forms示例,该示例使用AndHud for Android和BTProgressHud for iOS(或类似的东西)?
我知道这里有ACR-Xamarin-Forms示例https://github.com/aritchie/acr-xamarin-forms,但它太复杂了,完全超出了我的想象.
当然有一个更简单易懂的实现,但如果没有关于如何开始实现它的某种指导(对于C#和Xamarin新手)
提前致谢
有人可以解释Xamarin.Forms中的GridLayout引用吗?
使用FormsGallery上的示例,这里也可以看到http://iosapi.xamarin.com/?link=T%3aXamarin.Forms.Grid(也有图像)我试图解决它,但我的试验和错误没有非常成功,非常耗时.
查看网格的第一行,代码如下
grid.Children.Add(new Label
{
Text = "Grid",
Font = Font.BoldSystemFontOfSize(50),
HorizontalOptions = LayoutOptions.Center
}, 0, 3, 0, 1);
Run Code Online (Sandbox Code Playgroud)
它看起来好像第一个0表示X位置,3表示列跨度,下一个0表示y位置,一个表示行跨度.但是使用它作为参考并尝试添加其他行和列它不起作用.如果他们的样本包含一些评论会很棒,但是因为他们不能告诉我GridLayout引用如何工作?
干杯
我是C#(几周)和Xamarin(大约一周)的新手.
我能够从教程"在Android上的ListView中显示实体集合"(//来自http://diptimayapatra.wordpress.com/2013/07/08/xamarin-display-entity-collection-in-listview)实现ListView适配器-in-android /)
我现在的问题是我不知道如何处理TextView文本上的click事件.
我的适配器的GetView代码是:
public override View GetView(int position, View convertView, ViewGroup parent)
{
var incident = incidents[position];
View view = convertView;
if(view == null)
{
view = context.LayoutInflater.Inflate(
Resource.Layout.ListViewTemplate, null);
}
view.FindViewById<TextView>(Resource.Id.tvIncident).Text =
string.Format("{0}", incident.title);
view.FindViewById<TextView>(Resource.Id.tvIncidentDescription).Text =
string.Format("{0}", incident.description);
return view;
}
Run Code Online (Sandbox Code Playgroud)
我的事件对象代码是:
public class Incident
{
public int id {get; set;}
public string title {get; set;}
public string description {get; set;}
public double latitude {get; set;}
public double longitude {get; set;}
}
Run Code Online (Sandbox Code Playgroud)
然后活动中的代码是 …
我有以下对象:
public class Notification : INotifyPropertyChanged
{
private bool _trafficNot;
public bool TrafficNot
{
get { return _trafficNot; }
set {
if (value.Equals(_trafficNot))
return;
_trafficNot = value;
OnPropertyChanged();
}
}
private bool _newsNot;
public bool NewsNot
{
get { return _newsNot; }
set
{
if (value.Equals(_newsNot))
return;
_newsNot = value;
OnPropertyChanged();
}
}
public event PropertyChangedEventHandler PropertyChanged;
void OnPropertyChanged([CallerMemberName]String propertyName=null)
{
var handler=PropertyChanged;
if(handler != null)
{
handler(this, new PropertyChangedEventArgs(propertyName));
}
}
}
Run Code Online (Sandbox Code Playgroud)
我从这样的对象获取数据://根据DB Notification notification = new Notification {中存储的内容设置通知对象 …
c# ×3
xamarin ×3
android ×2
layout ×2
camera ×1
currency ×1
data-binding ×1
grid ×1
ios ×1
javascript ×1
listview ×1
rounding ×1
scrollview ×1