gpt4 book ai didi

java - Android 枚举与字节值

转载 作者:行者123 更新时间:2023-12-01 18:44:25 24 4
gpt4 key购买 nike

这是C#枚举,我想将它转换为具有相同字节类型的java。请帮我解决这个问题。

    public enum DataType    { UNKNOWN                           = 0xFF, 
DATAUNAILABLE = 0x00,
NORMALBEAT = 0x01,
VFLUTTER = 0x02,
VFIB = 0x03,
VTACHY = 0x04,
ASYTOLE = 0x05,
PAUSE = 0x06,
};

最佳答案

这是 Android 示例:

package com.example.enumtest;

import android.os.Bundle;
import android.app.Activity;

public class MainActivity extends Activity {

enum DataType {
UNKNOWN(0xff),
DATAUNAILABLE(0x00),
NORMALBEAT(0x01),
VFLUTTER(0x02),
VFIB(0x03),
VTACHY(0x04),
ASYTOLE(0x05),
PAUSE(0x06);

private final byte id;

DataType(int id) {
this.id = (byte) id;
}

public byte getId() {
return this.id;
}
}

private DataType type = DataType.PAUSE;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}

关于java - Android 枚举与字节值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18464733/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com