小编Nad*_*zov的帖子

Avro架构.如何一次将类型设置为"记录"和"空"

我需要在Schema中将"record"类型与null类型混合使用.

"name":"specShape",
         "type":{
            "type":"record",
            "name":"noSpecShape",
            "fields":[
               {
                  "name":"bpSsc",
                  "type":"null",
                  "default":null,
                  "doc":"SampleValue: null"
               },...
Run Code Online (Sandbox Code Playgroud)

例如,对于某些数据,specShape可能为null.

所以,如果我将类型设置为

"name":"specShape",
         "type":{
            **"type":["record", "null"],**
            "name":"noSpecShape",
            "fields":[
               {
                  "name":"bpSsc",
                  "type":"null",
                  "default":null,
                  "doc":"SampleValue: null"
               },...
Run Code Online (Sandbox Code Playgroud)

它说

No type: {"type":["record","null"]...
Run Code Online (Sandbox Code Playgroud)

但是如果我将whoole类型设置为

"name":"specShape",
         **"type":[{
            "type":"record",
            "name":"noSpecShape",
            "fields":[
               {
                  "name":"bpSsc",
                  "type":"null",
                  "default":null,
                  "doc":"SampleValue: null"
               }, "null"]**,...
Run Code Online (Sandbox Code Playgroud)

它说

Not in union [{"type":"record"
Run Code Online (Sandbox Code Playgroud)

如何结合这两种类型?

union null schema record avro

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

android两指放大/缩小不起作用

我发现了这个 如何在 android 中为图像启用(两指)放大/缩小功能

在日志中我看到它正在工作但图像没有改变,我做错了什么?

这是我的 xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".ViewImage" >

    <ImageView
        android:id="@+id/myimage"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_alignParentLeft="true"
        android:layout_alignParentRight="true"
        android:layout_alignParentTop="true"
        android:layout_alignParentBottom="true" />

</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

这是我的代码

public class ViewImage extends Activity implements OnTouchListener {

    private SQLiteDatabase qdb;
    ImageView myimage;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_view_image);
        myimage = (ImageView) findViewById(R.id.myimage);
        DB db = new DB(this);
        qdb = db.getReadableDatabase();
        Bundle b = getIntent().getExtras();
        int img_id = b.getInt("img_id");
        Cursor c = qdb.rawQuery("select name,  comment from photos where _id="+img_id+"", null);
        if(c.moveToFirst()){
            String img_name …
Run Code Online (Sandbox Code Playgroud)

android zooming

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

上传文件时MultipartEntityBuilder中的NoClassDefFoundError

我想上传图片并将数据发送到服务器.我正在使用MultipartEntityBuilder.我在Android Studio上编码.

这是我的代码

HttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(config.api_url+"profile.php");

MultipartEntityBuilder builder = MultipartEntityBuilder.create();
builder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE);

if(mLastTakenImageAsJPEGFile!=null) {
    builder.addBinaryBody("image", mLastTakenImageAsJPEGFile);
}

builder.addTextBody("token", _appPrefs.getToken());
final HttpEntity reqEntity = builder.build();

httpPost.setEntity(reqEntity);
Run Code Online (Sandbox Code Playgroud)

我收到运行时错误

java.lang.NoClassDefFoundError: org.apache.http.entity.ContentType 
at 
org.apache.http.entity.mime.MultipartEntityBuilder.addBinaryBody(MultipartEntityBuilder.java:146)
Run Code Online (Sandbox Code Playgroud)

怎么解决这个?

android noclassdeffounderror contenttype android-studio

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