在我的PhotoCaptureActivity.java的onCreate()中,我有:
OrientationEventListener oeL = new OrientationEventListener(this) {
public void onOrientationChanged(int orientation) {
if (orientation == ORIENTATION_UNKNOWN) return;
try {
android.hardware.Camera.CameraInfo info =
new android.hardware.Camera.CameraInfo();
android.hardware.Camera.getCameraInfo(currentCameraId, info);
orientation = (orientation + 45) / 90 * 90;
int rotation = 0;
if (info.facing == CameraInfo.CAMERA_FACING_FRONT) {
rotation = (info.orientation - orientation + 360) % 360;
} else { // back-facing camera
rotation = (info.orientation + orientation) % 360;
}
if(camera != null) {
Camera.Parameters parameters = camera.getParameters();
parameters.setRotation(rotation);
savingRotation = rotation;
} …Run Code Online (Sandbox Code Playgroud) 我知道这是一个愚蠢的问题,但我无法在任何地方找到答案.如何在sqlite.net模型中为列设置默认值?这是我的模型类:
public class ItemTaxes
{
[PrimaryKey]
public string Sku { get; set;}
public bool IsTaxable { get; set;}// How to set IsTaxable's default value to true?
public decimal PriceTaxExclusive { get; set;}
}
Run Code Online (Sandbox Code Playgroud)
我想将Not Null列IsTaxable的默认值设置为true,我该如何实现?顺便说一句我不想使用原始的sql语句,即conn.execute();
谢谢.
class TableObj1 {
public string Id {get; set;}
public string Name {get; set;}
}
class TableObj2 {
public string Id {get; set;}
public string Email {get; set;}
}
class MergeObj {
public TableObj1 Obj1 {get; set;}
public TableObj2 Obj2 {get; set;}
}
Run Code Online (Sandbox Code Playgroud)
我的问题是如何在连接两个表时返回MergeObj列表.我试过了:
public IEnumerable<MergeObj> QueryJoin() {
return (
from obj1 in conn.Table<TableObj1>()
join obj2 in conn.Table<TableObj2>()
on obj1.Id
equals obj2.Id
select new MergeObj{Obj1 = obj1, Obj2 = obj2}
);
}
void main() {
IEnumerable<MergeObj> mergeObjs = QueryJoin();
}
Run Code Online (Sandbox Code Playgroud)
但是QueryJoin()给出了Exception:System.NotSupportedException,不支持连接. …
<body>
<div>
<input type="text">
</div>
<span>
<input type="text">
</span>
</body>
Run Code Online (Sandbox Code Playgroud)
我的问题很简单.为什么div的宽度与其父级的宽度相同,而span的宽度比其父级的宽度短?即如果body的宽度是1000px,那么div也有1000px,但是span只有300px(从不同的浏览器波动)
我知道async await非常方便在设置适配器之前为ListView/GridView准备数据.例如:
// in Activity.cs
async void OnCreate(Bundle SavedInstanceState)
{
SetContentView(...);
ListView listView = FindViewById<ListView>(...);
AdapterData data = await Task.Run(() => GetDataFromWorkerThread);
listView.SetAdapter(data);
}
Run Code Online (Sandbox Code Playgroud)
但我需要的是:
// in ListViewAdapter.cs
public override View GetView (int position, View convertView, ViewGroup parent)
{
if(convertView == null)
{
// create new view
}
ImageView imgView = convertView.FindViewById<ImageView>(Resouce.Id.img_view_id);
ResizeImageAsync(imgView, imgResId);
return convertView; // convertView is returned before ImageView is assigned with resized image
}
private async void ResizeImageAsync(ImageView imageView, int imgResId)
{
Bitmap bmp = await …Run Code Online (Sandbox Code Playgroud) 我是c#异步等待机制的新手.我一直在阅读一些关于异步的文章(http://blog.stephencleary.com/2012/07/dont-block-on-async-code.html).我在下面有一个例子,如果第Initialize一种方法会导致死锁,为什么还能告诉我?先感谢您.
public class Test {
public async Task DoSomeWorkAsync() {
await DoSomeWork1Async();
}
// This method is mixed with Wait and async await, will this cause lead lock?
public void Initialize() {
Task.Run(() => DoSomeWorkAsync()).Wait();
}
// This method is following async all the way
public async Task InitializeAsync() {
await DoSomeWorkAsync();
}
}
// Update: Here is the context where two Initialize methods are called
public class TestForm : Form {
// Load Form UI …Run Code Online (Sandbox Code Playgroud) c# ×4
android ×2
async-await ×2
sqlite.net ×2
xamarin ×2
.net ×1
css3 ×1
html ×1
linq ×1
wait ×1