小编mac*_*Jun的帖子

java.lang.RuntimeException:无法获取摄像头信息

在我的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)

android

15
推荐指数
1
解决办法
3485
查看次数

如何在不使用sqlite raw语句/ conn.execute()的情况下为Sqlite.net设置默认值

我知道这是一个愚蠢的问题,但我无法在任何地方找到答案.如何在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 NullIsTaxable的默认值设置为true,我该如何实现?顺便说一句我不想使用原始的sql语句,即conn.execute();

谢谢.

c# xamarin sqlite.net

11
推荐指数
2
解决办法
4268
查看次数

如何使用linq返回TableOjb1和TableObj2的Wrapper obj

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,不支持连接. …

c# linq sqlite.net

7
推荐指数
1
解决办法
383
查看次数

当span用于包含<input type ="text">时,为什么span默认设计为宽度小于其父元素的宽度?

<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(从不同的浏览器波动)

html css3

2
推荐指数
1
解决办法
131
查看次数

图像被分配给ListView的另一个行项目

我知道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# android xamarin.android async-await xamarin

2
推荐指数
1
解决办法
1438
查看次数

async一直等待异步

我是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)

.net c# wait task-parallel-library async-await

1
推荐指数
1
解决办法
381
查看次数